Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sorentwo committed Nov 10, 2014
1 parent 64bee3b commit 20e686b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
12 changes: 8 additions & 4 deletions examples/upstart/manage-many/sidekiq.conf
Expand Up @@ -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

Expand All @@ -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
15 changes: 10 additions & 5 deletions examples/upstart/manage-one/sidekiq.conf
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 20e686b

Please sign in to comment.