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
|
||||
# this script runs in /bin/sh by default
|
||||
# respawn as bash so we can source in rbenv
|
||||
exec /bin/bash <<EOT
|
||||
# uncomment to use syslog for logging
|
||||
# exec &> /dev/kmsg
|
||||
exec /bin/bash <<'EOT'
|
||||
# Use a named pipe directed at logger for system logging.
|
||||
fifopath = '/tmp/sidekiq-log-fifo'
|
||||
mkfifo $fifopath
|
||||
(logger -t sidekiq < $fifopath &)
|
||||
exec > $fifopath
|
||||
rm $fifopath
|
||||
|
||||
export HOME=/home/apps
|
||||
|
||||
|
@ -82,6 +86,6 @@ exec /bin/bash <<EOT
|
|||
logger -t sidekiq "Stopping process: $app-$index"
|
||||
|
||||
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
|
||||
end script
|
||||
|
|
|
@ -28,7 +28,8 @@ env HOME=/home/deploy
|
|||
respawn
|
||||
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
|
||||
|
||||
instance $index
|
||||
|
@ -37,18 +38,22 @@ script
|
|||
# this script runs in /bin/sh by default
|
||||
# respawn as bash so we can source in rbenv
|
||||
exec /bin/bash <<'EOT'
|
||||
# use syslog for logging
|
||||
exec &> /dev/kmsg
|
||||
# Use a named pipe directed at logger for system logging.
|
||||
fifopath = '/tmp/sidekiq-log-fifo'
|
||||
mkfifo $fifopath
|
||||
(logger -t sidekiq < $fifopath &)
|
||||
exec > $fifopath
|
||||
rm $fifopath
|
||||
|
||||
# pull in system rbenv
|
||||
source /etc/profile.d/rbenv.sh
|
||||
# or
|
||||
# or
|
||||
# pull in user installed rbenv
|
||||
# export PATH="$HOME/.rbenv/bin:$PATH"
|
||||
# eval "$(rbenv init -)"
|
||||
# export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
|
||||
|
||||
cd /opt/theclymb/current
|
||||
exec bin/sidekiq -i ${index} -e production
|
||||
exec bin/sidekiq -i ${index} -e production 2> /dev/null
|
||||
EOT
|
||||
end script
|
||||
|
|
Loading…
Add table
Reference in a new issue