diff options
-rwxr-xr-x | config/alert-tracks-debian.ugly | 13 | ||||
-rw-r--r-- | config/deploy.rb | 2 | ||||
-rw-r--r-- | config/general.yml-example | 1 | ||||
-rwxr-xr-x[-rw-r--r--] | config/purge-varnish-debian.ugly | 12 | ||||
-rw-r--r-- | doc/CHANGES.md | 5 | ||||
-rw-r--r-- | lib/tasks/config_files.rake | 23 |
6 files changed, 41 insertions, 15 deletions
diff --git a/config/alert-tracks-debian.ugly b/config/alert-tracks-debian.ugly index c7d82d8c8..f1ca68b03 100755 --- a/config/alert-tracks-debian.ugly +++ b/config/alert-tracks-debian.ugly @@ -13,10 +13,12 @@ # !!(*= $daemon_name *)!! Start the Alaveteli email alert daemon NAME=!!(*= $daemon_name *)!! -DAEMON=!!(*= $vhost_dir *)!!/alaveteli/script/runner +DAEMON=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/runner DAEMON_ARGS="--daemon TrackMailer.alert_tracks_loop" -PIDFILE=!!(*= $vhost_dir *)!!/alert-tracks.pid -LOGFILE=!!(*= $vhost_dir *)!!/alaveteli/log/alert-tracks.log +PIDDIR=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/tmp/pids +PIDFILE=$PIDDIR/!!(*= $daemon_name *)!!.pid +LOGDIR=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/log +LOGFILE=$LOGDIR/!!(*= $daemon_name *)!!.log DUSER=!!(*= $user *)!! # Set RAILS_ENV - not needed if using config/rails_env.rb # RAILS_ENV=your_rails_env @@ -27,10 +29,14 @@ trap "" 1 export PIDFILE LOGFILE quietly_start_daemon() { + mkdir -p {$LOGDIR,$PIDDIR} + chown $DUSER:$DUSER {$LOGDIR,$PIDDIR} /sbin/start-stop-daemon --quiet --start --pidfile "$PIDFILE" --chuid "$DUSER" --startas "$DAEMON" -- $DAEMON_ARGS } start_daemon() { + mkdir -p {$LOGDIR,$PIDDIR} + chown $DUSER:$DUSER {$LOGDIR,$PIDDIR} /sbin/start-stop-daemon --start --pidfile "$PIDFILE" --chuid "$DUSER" --startas "$DAEMON" -- $DAEMON_ARGS } @@ -81,4 +87,3 @@ else echo " failed" exit 1 fi - diff --git a/config/deploy.rb b/config/deploy.rb index 9cc847dba..afc586ecf 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -57,6 +57,7 @@ namespace :deploy do "#{release_path}/files" => "#{shared_path}/files", "#{release_path}/cache" => "#{shared_path}/cache", "#{release_path}/log" => "#{shared_path}/log", + "#{release_path}/tmp/pids" => "#{shared_path}/tmp/pids", "#{release_path}/lib/acts_as_xapian/xapiandbs" => "#{shared_path}/xapiandbs", } @@ -68,6 +69,7 @@ namespace :deploy do run "mkdir -p #{shared_path}/files" run "mkdir -p #{shared_path}/cache" run "mkdir -p #{shared_path}/log" + run "mkdir -p #{shared_path}/tmp/pids" run "mkdir -p #{shared_path}/xapiandbs" end end diff --git a/config/general.yml-example b/config/general.yml-example index a6f68c52e..0f32f6192 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -246,6 +246,7 @@ SHARED_DIRECTORIES: - cache/ - lib/acts_as_xapian/xapiandbs/ - log/ + - tmp/pids - vendor/bundle - public/assets diff --git a/config/purge-varnish-debian.ugly b/config/purge-varnish-debian.ugly index ebd4d9e5c..dc3f74ff6 100644..100755 --- a/config/purge-varnish-debian.ugly +++ b/config/purge-varnish-debian.ugly @@ -13,10 +13,12 @@ # !!(*= $daemon_name *)!! Start the Alaveteli email purge-varnish daemon NAME=!!(*= $daemon_name *)!! -DAEMON=!!(*= $vhost_dir *)!!/alaveteli/script/runner +DAEMON=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/script/runner DAEMON_ARGS="--daemon PurgeRequest.purge_all_loop" -PIDFILE=!!(*= $vhost_dir *)!!/purge-varnish.pid -LOGFILE=!!(*= $vhost_dir *)!!/alaveteli/log/purge-varnish.log +PIDDIR=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/tmp/pids +PIDFILE=$PIDDIR/!!(*= $daemon_name *)!!.pid +LOGDIR=!!(*= $vhost_dir *)!!/!!(*= $vcspath *)!!/log +LOGFILE=$LOGDIR/!!(*= $daemon_name *)!!.log DUSER=!!(*= $user *)!! # Set RAILS_ENV - not needed if using config/rails_env.rb # RAILS_ENV=your_rails_env @@ -29,10 +31,14 @@ trap "" 1 export PIDFILE LOGFILE quietly_start_daemon() { + mkdir -p {$LOGDIR,$PIDDIR} + chown $DUSER:$DUSER {$LOGDIR,$PIDDIR} /sbin/start-stop-daemon --quiet --start --pidfile "$PIDFILE" --chuid "$DUSER" --startas "$DAEMON" -- $DAEMON_ARGS } start_daemon() { + mkdir -p {$LOGDIR,$PIDDIR} + chown $DUSER:$DUSER {$LOGDIR,$PIDDIR} /sbin/start-stop-daemon --start --pidfile "$PIDFILE" --chuid "$DUSER" --startas "$DAEMON" -- $DAEMON_ARGS } diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 0032706ef..61f55211c 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -4,6 +4,11 @@ ## Upgrade Notes +* The `SHARED_DIRECTORIES` setting now includes `tmp/pids`. The notes below for + updating the log directory should cover the update steps for `tmp/pids`. +* Capistrano now creates `SHARED_PATH/tmp/pids` and links `APP_ROOT/tmp/pids` + here, as the alert tracks daemon writes its pids to the generally expected + location of `APP_ROOT/tmp/pids`. * rails-post-deploy no longer handles linking `APP_ROOT/log` to a log directory outside the app. Capistrano users will find that `:symlink_configuration` now links `APP_ROOT/log` to `SHARED_PATH/log`. Users who aleady use the diff --git a/lib/tasks/config_files.rake b/lib/tasks/config_files.rake index 60814cb27..438b63fc0 100644 --- a/lib/tasks/config_files.rake +++ b/lib/tasks/config_files.rake @@ -23,26 +23,33 @@ namespace :config_files do desc 'Convert Debian .ugly init script in config to a form suitable for installing in /etc/init.d' task :convert_init_script => :environment do - example = 'rake config_files:convert_init_script DEPLOY_USER=deploy VHOST_DIR=/dir/above/alaveteli SCRIPT_FILE=config/alert-tracks-debian.ugly ' - check_for_env_vars(['DEPLOY_USER', 'VHOST_DIR', 'SCRIPT_FILE'], example) + example = 'rake config_files:convert_init_script DEPLOY_USER=deploy VHOST_DIR=/dir/above/alaveteli VCSPATH=alaveteli SITE=alaveteli SCRIPT_FILE=config/alert-tracks-debian.ugly' + check_for_env_vars(['DEPLOY_USER', + 'VHOST_DIR', + 'SCRIPT_FILE'], example) - deploy_user = ENV['DEPLOY_USER'] - vhost_dir = ENV['VHOST_DIR'] script_file = ENV['SCRIPT_FILE'] + site = ENV.fetch('SITE', 'foi') - replacements = { :user => deploy_user, - :vhost_dir => vhost_dir } + replacements = { + :user => ENV['DEPLOY_USER'], + :vhost_dir => ENV['VHOST_DIR'], + :vcspath => ENV.fetch('VCSPATH', 'alaveteli'), + :site => site + } daemon_name = File.basename(script_file, '-debian.ugly') - replacements.update(:daemon_name => "foi-#{daemon_name}") + replacements.update(:daemon_name => "#{ site }-#{ daemon_name }") converted = convert_ugly(script_file, replacements) rails_env_file = File.expand_path(File.join(Rails.root, 'config', 'rails_env.rb')) - if !File.exists?(rails_env_file) + + unless File.exists?(rails_env_file) converted.each do |line| line.gsub!(/^#\s*RAILS_ENV=your_rails_env/, "RAILS_ENV=#{Rails.env}") line.gsub!(/^#\s*export RAILS_ENV/, "export RAILS_ENV") end end + converted.each do |line| puts line end |