Skip to content

Commit

Permalink
feat: switch to null buildpack for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
josegonzalez committed Jun 20, 2020
1 parent 81717f6 commit 008b362
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests/apps/python/.buildpacks
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/dokku/buildpack-null.git
5 changes: 5 additions & 0 deletions tests/apps/python/CHECKS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
WAIT=2 # wait 2 seconds
TIMEOUT=5 # set timeout to 5 seconds
ATTEMPTS=2 # try 2 times

/ python/http.server
54 changes: 54 additions & 0 deletions tests/apps/python/Procfile
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions tests/apps/python/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"scripts": {
"dokku": {
"predeploy": "touch /app/predeploy.test",
"postdeploy": "touch /app/postdeploy.test"
}
}
}
5 changes: 5 additions & 0 deletions tests/apps/python/check_deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -e
output="$(curl -s -S "$1")"
echo "$output"
test "$output" == "python/http.server"
Empty file added tests/apps/python/null
Empty file.
17 changes: 17 additions & 0 deletions tests/apps/python/web.py
Original file line number Diff line number Diff line change
@@ -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()
11 changes: 11 additions & 0 deletions tests/apps/python/worker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import time


def main():
print("sleeping for 60 seconds")
while True:
time.sleep(60)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion tests/unit/test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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:="[email protected]:$TEST_APP"}
local GIT_REMOTE_BRANCH=${GIT_REMOTE_BRANCH:="master"}
local TMP=${CUSTOM_TMP:=$(mktemp -d "/tmp/dokku.me.XXXXX")}
Expand Down

0 comments on commit 008b362

Please sign in to comment.