Skip to content

Commit

Permalink
thumbor service can run as multiple processes using upstart
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy92 committed Jan 24, 2013
1 parent 65f4fa1 commit 2a52a9a
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 19 deletions.
3 changes: 2 additions & 1 deletion debian/rules
Expand Up @@ -24,8 +24,9 @@ binary-arch: build-arch
dh_testroot dh_testroot
dh_prep dh_prep
python$(PYTHON2) debsetup.py install --root=$(CURDIR)/debian/tmp --install-layout=deb 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.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_install --exclude=.c
dh_python2 dh_python2
dh_strip dh_strip
Expand Down
23 changes: 23 additions & 0 deletions debian/thumbor-worker.upstart
@@ -0,0 +1,23 @@
description "Thumbor image manipulation service"
author "Wichert Akkerman <wichert@wiggy.net>"

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}"
12 changes: 8 additions & 4 deletions 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 # you can temporarily override this with
# sudo service thumbor start force_start=1 # sudo service thumbor start force=1
enabled=0 enabled=0


# Location of the configuration file # Location of the configuration file
Expand All @@ -12,5 +12,9 @@ conffile=/etc/thumbor.conf
# IP address to bind to. Defaults to all IP addresses # IP address to bind to. Defaults to all IP addresses
# ip=127.0.0.1 # ip=127.0.0.1


# TCP port to bind to. Defaults to port 8888 # TCP port to bind to. Defaults to port 8888.
# port=8888 # multiple instances of thumbor can be started by putting several ports coma separeted
# Ex:
# port=8888,8889,8890
# or
# port=8888 #Default
23 changes: 9 additions & 14 deletions debian/thumbor.upstart
Expand Up @@ -4,23 +4,18 @@ author "Wichert Akkerman <wichert@wiggy.net>"
start on filesystem and runlevel [2345] start on filesystem and runlevel [2345]
stop on runlevel [!2345] stop on runlevel [!2345]


respawn console output
respawn limit 5 10
umask 022


setuid thumbor
setgid thumbor

env conffile=/etc/thumbor.conf
env keyfile=/etc/thumbor.key
env ip=0.0.0.0
env port=8888 env port=8888


chdir /var/lib/thumbor

pre-start script pre-start script
[ -r /etc/default/thumbor ] && . /etc/default/thumbor [ -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 end script

exec /usr/bin/thumbor -c "${conffile}" -i "${ip}" -p "${port}" -k "${keyfile}"

0 comments on commit 2a52a9a

Please sign in to comment.