From 2a52a9abbfb700bf55c98ee74c286c2ff84134b3 Mon Sep 17 00:00:00 2001 From: dhardy92 Date: Thu, 24 Jan 2013 17:49:21 +0100 Subject: [PATCH] thumbor service can run as multiple processes using upstart --- debian/rules | 3 ++- debian/thumbor-worker.upstart | 23 +++++++++++++++++++++++ debian/thumbor.default | 12 ++++++++---- debian/thumbor.upstart | 23 +++++++++-------------- 4 files changed, 42 insertions(+), 19 deletions(-) create mode 100644 debian/thumbor-worker.upstart diff --git a/debian/rules b/debian/rules index 1db0d4234..198ec2a1f 100755 --- a/debian/rules +++ b/debian/rules @@ -24,8 +24,9 @@ binary-arch: build-arch dh_testroot dh_prep python$(PYTHON2) debsetup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb - install -d -o root -g root -m 755 debian/thumbor/etc + install -d -o root -g root -m 755 debian/thumbor/etc debian/thumbor/etc/init/ install -p -o root -g root -m 644 debian/thumbor.conf debian/thumbor/etc + install -p -o root -g root -m 644 debian/thumbor-worker.upstart debian/thumbor/etc/init/thumbor-worker.conf dh_install --exclude=.c dh_python2 dh_strip diff --git a/debian/thumbor-worker.upstart b/debian/thumbor-worker.upstart new file mode 100644 index 000000000..f2d02681d --- /dev/null +++ b/debian/thumbor-worker.upstart @@ -0,0 +1,23 @@ +description "Thumbor image manipulation service" +author "Wichert Akkerman " + +stop on stopped thumbor + +respawn +respawn limit 5 10 +umask 022 + +setuid thumbor +setgid thumbor + +env DAEMON=/usr/bin/thumbor + +env conffile=/etc/thumbor.conf +env keyfile=/etc/thumbor.key +env ip=0.0.0.0 + +chdir /var/lib/thumbor + +instance $p + +exec $DAEMON -c "${conffile}" -i "${ip}" -k "${keyfile}" -p "${p}" diff --git a/debian/thumbor.default b/debian/thumbor.default index 3d5365416..569f0f7e3 100644 --- a/debian/thumbor.default +++ b/debian/thumbor.default @@ -1,6 +1,6 @@ -# set this to 0 to disable thumboer, or to 1 to enable it +# set this to 0 to disable thumbor, remove or set anything else to enable it # you can temporarily override this with -# sudo service thumbor start force_start=1 +# sudo service thumbor start force=1 enabled=0 # Location of the configuration file @@ -12,5 +12,9 @@ conffile=/etc/thumbor.conf # IP address to bind to. Defaults to all IP addresses # ip=127.0.0.1 -# TCP port to bind to. Defaults to port 8888 -# port=8888 +# TCP port to bind to. Defaults to port 8888. +# multiple instances of thumbor can be started by putting several ports coma separeted +# Ex: +# port=8888,8889,8890 +# or +# port=8888 #Default diff --git a/debian/thumbor.upstart b/debian/thumbor.upstart index ae49954a5..a5dcc8e81 100644 --- a/debian/thumbor.upstart +++ b/debian/thumbor.upstart @@ -4,23 +4,18 @@ author "Wichert Akkerman " start on filesystem and runlevel [2345] stop on runlevel [!2345] -respawn -respawn limit 5 10 -umask 022 +console output -setuid thumbor -setgid thumbor - -env conffile=/etc/thumbor.conf -env keyfile=/etc/thumbor.key -env ip=0.0.0.0 env port=8888 -chdir /var/lib/thumbor - pre-start script [ -r /etc/default/thumbor ] && . /etc/default/thumbor - [ "$enabled" = "1" ] || [ "$force_start" = "1" ] || exit 0 + if [ "$enabled" = "0" ] && [ "$force" != "1" ] ; then + logger -is -t "$UPSTART_JOB" "Thumbor is disabled by /etc/default/thumbor, add force=1 to your service command" + stop + exit 0 + fi + for p in `echo ${port} | tr ',' ' '`; do + start thumbor-worker p=$p + done end script - -exec /usr/bin/thumbor -c "${conffile}" -i "${ip}" -p "${port}" -k "${keyfile}"