Permalink
Browse files

thumbor service can run as multiple processes using upstart

  • Loading branch information...
1 parent 65f4fa1 commit 2a52a9abbfb700bf55c98ee74c286c2ff84134b3 @dhardy92 dhardy92 committed Jan 24, 2013
Showing with 42 additions and 19 deletions.
  1. +2 −1 debian/rules
  2. +23 −0 debian/thumbor-worker.upstart
  3. +8 −4 debian/thumbor.default
  4. +9 −14 debian/thumbor.upstart
View
@@ -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
@@ -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}"
View
@@ -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
View
@@ -4,23 +4,18 @@ author "Wichert Akkerman <wichert@wiggy.net>"
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}"

0 comments on commit 2a52a9a

Please sign in to comment.