mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Use a named pipe for logging in upstart example
The ability to log directly to /dev/kmsg was removed in Ubuntu 14.04, making the existing example config fail to perform any real logging. Appending a pipe to the last `exec` within the `script` block gives upstart an incorrect PID to work with, which can lead to various issues. This uses a FIFO solution that logs to syslog at any permission level and doesn't leave anything on the file system afterwards.
This commit is contained in:
parent
64bee3bb83
commit
20e686be3a
2 changed files with 18 additions and 9 deletions
|
@ -62,9 +62,13 @@ end script
|
||||||
pre-stop script
|
pre-stop script
|
||||||
# this script runs in /bin/sh by default
|
# this script runs in /bin/sh by default
|
||||||
# respawn as bash so we can source in rbenv
|
# respawn as bash so we can source in rbenv
|
||||||
exec /bin/bash <<EOT
|
exec /bin/bash <<'EOT'
|
||||||
# uncomment to use syslog for logging
|
# Use a named pipe directed at logger for system logging.
|
||||||
# exec &> /dev/kmsg
|
fifopath = '/tmp/sidekiq-log-fifo'
|
||||||
|
mkfifo $fifopath
|
||||||
|
(logger -t sidekiq < $fifopath &)
|
||||||
|
exec > $fifopath
|
||||||
|
rm $fifopath
|
||||||
|
|
||||||
export HOME=/home/apps
|
export HOME=/home/apps
|
||||||
|
|
||||||
|
@ -82,6 +86,6 @@ exec /bin/bash <<EOT
|
||||||
logger -t sidekiq "Stopping process: $app-$index"
|
logger -t sidekiq "Stopping process: $app-$index"
|
||||||
|
|
||||||
cd $app
|
cd $app
|
||||||
exec bundle exec sidekiqctl stop tmp/pids/${app}-${index}.pid
|
exec bundle exec sidekiqctl stop tmp/pids/${app}-${index}.pid 2> /dev/null
|
||||||
EOT
|
EOT
|
||||||
end script
|
end script
|
||||||
|
|
|
@ -28,7 +28,8 @@ env HOME=/home/deploy
|
||||||
respawn
|
respawn
|
||||||
respawn limit 3 30
|
respawn limit 3 30
|
||||||
|
|
||||||
# TERM is sent by sidekiqctl when stopping sidekiq. Without declaring these as normal exit codes, it just respawns.
|
# TERM is sent by sidekiqctl when stopping sidekiq. Without declaring these as
|
||||||
|
# normal exit codes, it just respawns.
|
||||||
normal exit 0 TERM
|
normal exit 0 TERM
|
||||||
|
|
||||||
instance $index
|
instance $index
|
||||||
|
@ -37,8 +38,12 @@ script
|
||||||
# this script runs in /bin/sh by default
|
# this script runs in /bin/sh by default
|
||||||
# respawn as bash so we can source in rbenv
|
# respawn as bash so we can source in rbenv
|
||||||
exec /bin/bash <<'EOT'
|
exec /bin/bash <<'EOT'
|
||||||
# use syslog for logging
|
# Use a named pipe directed at logger for system logging.
|
||||||
exec &> /dev/kmsg
|
fifopath = '/tmp/sidekiq-log-fifo'
|
||||||
|
mkfifo $fifopath
|
||||||
|
(logger -t sidekiq < $fifopath &)
|
||||||
|
exec > $fifopath
|
||||||
|
rm $fifopath
|
||||||
|
|
||||||
# pull in system rbenv
|
# pull in system rbenv
|
||||||
source /etc/profile.d/rbenv.sh
|
source /etc/profile.d/rbenv.sh
|
||||||
|
@ -49,6 +54,6 @@ exec /bin/bash <<'EOT'
|
||||||
# export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
|
# export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
|
||||||
|
|
||||||
cd /opt/theclymb/current
|
cd /opt/theclymb/current
|
||||||
exec bin/sidekiq -i ${index} -e production
|
exec bin/sidekiq -i ${index} -e production 2> /dev/null
|
||||||
EOT
|
EOT
|
||||||
end script
|
end script
|
||||||
|
|
Loading…
Add table
Reference in a new issue