diff --git a/tests/apps/python/.buildpacks b/tests/apps/python/.buildpacks new file mode 100644 index 000000000..b86e298c6 --- /dev/null +++ b/tests/apps/python/.buildpacks @@ -0,0 +1 @@ +https://github.com/dokku/buildpack-null.git diff --git a/tests/apps/python/CHECKS b/tests/apps/python/CHECKS new file mode 100644 index 000000000..52a9225d1 --- /dev/null +++ b/tests/apps/python/CHECKS @@ -0,0 +1,5 @@ +WAIT=2 # wait 2 seconds +TIMEOUT=5 # set timeout to 5 seconds +ATTEMPTS=2 # try 2 times + +/ python/http.server diff --git a/tests/apps/python/Procfile b/tests/apps/python/Procfile new file mode 100644 index 000000000..def474954 --- /dev/null +++ b/tests/apps/python/Procfile @@ -0,0 +1,54 @@ +############################### +# DEVELOPMENT # +############################### + +# Procfile for development using the new threaded worker (scheduler, twitter stream and delayed job) +cron: python3 worker.py +web: python3 web.py # testing inline comment +worker: python3 worker.py +custom: echo -n +release: touch /app/release.test + + +# Old version with separate processes (use this if you have issues with the threaded version) +# web: bundle exec rails server +# schedule: bundle exec rails runner bin/schedule.rb +# twitter: bundle exec rails runner bin/twitter_stream.rb +# dj: bundle exec script/delayed_job run + +############################### +# PRODUCTION # +############################### + +# You need to copy or link config/unicorn.rb.example to config/unicorn.rb for both production versions. +# Have a look at the deployment guides, if you want to set up huginn on your server: +# https://github.com/cantino/huginn/doc + +# Using the threaded worker (consumes less RAM but can run slower) +# web: bundle exec unicorn -c config/unicorn.rb +# jobs: bundle exec rails runner bin/threaded.rb + +# Old version with separate processes (use this if you have issues with the threaded version) +# web: bundle exec unicorn -c config/unicorn.rb +# schedule: bundle exec rails runner bin/schedule.rb +# twitter: bundle exec rails runner bin/twitter_stream.rb +# dj: bundle exec script/delayed_job run + +############################### +# Multiple DelayedJob workers # +############################### +# Per default Huginn can just run one agent at a time. Using a lot of agents or calling slow +# external services frequently might require more DelayedJob workers (an indicator for this is +# a backlog in your 'Job Management' page). +# Every uncommented line starts an additional DelayedJob worker. This works for development, production +# and for the threaded and separate worker processes. Keep in mind one worker needs about 300MB of RAM. +# +#dj2: bundle exec script/delayed_job -i 2 run +#dj3: bundle exec script/delayed_job -i 3 run +#dj4: bundle exec script/delayed_job -i 4 run +#dj5: bundle exec script/delayed_job -i 5 run +#dj6: bundle exec script/delayed_job -i 6 run +#dj7: bundle exec script/delayed_job -i 7 run +#dj8: bundle exec script/delayed_job -i 8 run +#dj9: bundle exec script/delayed_job -i 9 run +#dj10: bundle exec script/delayed_job -i 10 run diff --git a/tests/apps/python/app.json b/tests/apps/python/app.json new file mode 100644 index 000000000..0dbdea3ec --- /dev/null +++ b/tests/apps/python/app.json @@ -0,0 +1,8 @@ +{ + "scripts": { + "dokku": { + "predeploy": "touch /app/predeploy.test", + "postdeploy": "touch /app/postdeploy.test" + } + } +} diff --git a/tests/apps/python/check_deploy b/tests/apps/python/check_deploy new file mode 100644 index 000000000..db53f009f --- /dev/null +++ b/tests/apps/python/check_deploy @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -e +output="$(curl -s -S "$1")" +echo "$output" +test "$output" == "python/http.server" diff --git a/tests/apps/python/null b/tests/apps/python/null new file mode 100644 index 000000000..e69de29bb diff --git a/tests/apps/python/web.py b/tests/apps/python/web.py new file mode 100644 index 000000000..b3e8ef728 --- /dev/null +++ b/tests/apps/python/web.py @@ -0,0 +1,17 @@ +import http.server +import os + + +class GetHandler(http.server.BaseHTTPRequestHandler): + def do_GET(self): + self.send_response(200) + self.send_header("Content-Type", "text/plain; charset=utf-8") + self.end_headers() + self.wfile.write("python/http.server".encode("utf-8")) + + +if __name__ == "__main__": + port = int(os.getenv("PORT", 5000)) + server = http.server.HTTPServer(("0.0.0.0", port), GetHandler) + print("Listening on port {0}".format(port)) + server.serve_forever() diff --git a/tests/apps/python/worker.py b/tests/apps/python/worker.py new file mode 100644 index 000000000..30fd58b59 --- /dev/null +++ b/tests/apps/python/worker.py @@ -0,0 +1,11 @@ +import time + + +def main(): + print("sleeping for 60 seconds") + while True: + time.sleep(60) + + +if __name__ == "__main__": + main() diff --git a/tests/unit/test_helper.bash b/tests/unit/test_helper.bash index 4bba6f132..99cef20d5 100644 --- a/tests/unit/test_helper.bash +++ b/tests/unit/test_helper.bash @@ -263,7 +263,7 @@ assert_urls() { deploy_app() { declare APP_TYPE="$1" GIT_REMOTE="$2" CUSTOM_TEMPLATE="$3" CUSTOM_PATH="$4" - local APP_TYPE=${APP_TYPE:="nodejs-express"} + local APP_TYPE=${APP_TYPE:="python"} local GIT_REMOTE=${GIT_REMOTE:="dokku@dokku.me:$TEST_APP"} local GIT_REMOTE_BRANCH=${GIT_REMOTE_BRANCH:="master"} local TMP=${CUSTOM_TMP:=$(mktemp -d "/tmp/dokku.me.XXXXX")}