diff options
-rw-r--r-- | config/deploy.rb | 5 | ||||
-rw-r--r-- | config/deploy.yml.example | 2 | ||||
-rwxr-xr-x | config/sysvinit-thin.ugly | 8 | ||||
-rw-r--r-- | doc/CHANGES.md | 7 | ||||
-rwxr-xr-x | script/site-specific-install.sh | 8 |
5 files changed, 24 insertions, 6 deletions
diff --git a/config/deploy.rb b/config/deploy.rb index c1954d058..f4a0b536a 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -14,6 +14,7 @@ set :deploy_to, configuration['deploy_to'] set :user, configuration['user'] set :use_sudo, false set :rails_env, configuration['rails_env'] +set :daemon_name, configuration.fetch('daemon_name', 'alaveteli') server configuration['server'], :app, :web, :db, :primary => true @@ -35,9 +36,9 @@ end namespace :deploy do [:start, :stop, :restart].each do |t| - desc "#{t.to_s.capitalize} Alaveteli service defined in /etc/init.d/alaveteli" + desc "#{t.to_s.capitalize} Alaveteli service defined in /etc/init.d/" task t, :roles => :app, :except => { :no_release => true } do - run "/etc/init.d/alaveteli #{t}" + run "service #{ daemon_name } #{ t }" end end diff --git a/config/deploy.yml.example b/config/deploy.yml.example index a20eb3c22..93aba439a 100644 --- a/config/deploy.yml.example +++ b/config/deploy.yml.example @@ -6,6 +6,7 @@ production: user: deploy rails_env: production deploy_to: /srv/www/alaveteli_production + daemon_name: alaveteli staging: repository: git://github.com/mysociety/alaveteli.git branch: develop @@ -13,3 +14,4 @@ staging: user: deploy rails_env: production deploy_to: /srv/www/alaveteli_staging + daemon_name: alaveteli_staging diff --git a/config/sysvinit-thin.ugly b/config/sysvinit-thin.ugly index b333f3738..0155ff8c3 100755 --- a/config/sysvinit-thin.ugly +++ b/config/sysvinit-thin.ugly @@ -22,7 +22,13 @@ RAILS_ENV=!!(*= $rails_env *)!! set -e # Check that the Daemon can be run -su -l -c "cd $SITE_HOME && bundle exec thin --version &> /dev/null || exit 0" $USER +CURRENT_USER=$(whoami) +if [ "$CURRENT_USER" = "$USER" ] + then + cd $SITE_HOME && bundle exec thin --version > /dev/null 2>&1 || exit 0 + else + su -l -c "cd $SITE_HOME && bundle exec thin --version &> /dev/null || exit 0" $USER +fi start_daemon() { echo -n "Starting $DESC: " diff --git a/doc/CHANGES.md b/doc/CHANGES.md index ea8010d5f..5ae96f293 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -41,6 +41,8 @@ name in multiple locales (Louise Crow). * No longer need to restart webserver when compacting Xapian database (Gareth Rees). +* `config/deploy.yml` now accepts a `daemon_name` parameter so that Capistrano + can deploy multiple Alaveteli instances on the same host (Gareth Rees). ## Upgrade notes @@ -60,6 +62,11 @@ * [Regenerate your crontab](http://alaveteli.org/docs/installing/manual_install/#generate-crontab) so that compacting the Xapian database only restarts the application, rather than the webserver. This requires the [appropriate SysVinit script](http://alaveteli.org/docs/installing/manual_install/#generate-application-daemon) to be installed. +* Alaveteli daemons must be executable by the app owner in a Capistrano setup. + In a regular setup, the permissions should be `rwxr-xr-- root:alaveteli`. +* `config/sysvinit-thin.ugly` has been improved. Regenerate it with + `rake config_files:convert_init_script`. See [the documentation](http://alaveteli.org/docs/installing/manual_install/#generate-application-daemon) + for more information. # Version 0.20 diff --git a/script/site-specific-install.sh b/script/site-specific-install.sh index 59b714fb7..fba164213 100755 --- a/script/site-specific-install.sh +++ b/script/site-specific-install.sh @@ -209,13 +209,15 @@ echo $DONE_MSG if [ ! "$DEVELOPMENT_INSTALL" = true ]; then echo -n "Creating /etc/init.d/$SITE... " (su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:convert_init_script DEPLOY_USER='$UNIX_USER' VHOST_DIR='$DIRECTORY' VCSPATH='$SITE' SITE='$SITE' SCRIPT_FILE=config/sysvinit-thin.ugly" "$UNIX_USER") > /etc/init.d/"$SITE" - chmod a+rx /etc/init.d/"$SITE" + chgrp "$UNIX_USER" /etc/init.d/"$SITE" + chmod 754 /etc/init.d/"$SITE" echo $DONE_MSG fi echo -n "Creating /etc/init.d/$SITE-alert-tracks... " -(su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:convert_init_script DEPLOY_USER='$UNIX_USER' VHOST_DIR='$DIRECTORY' SCRIPT_FILE=config/alert-tracks-debian.ugly" "$UNIX_USER") > /etc/init.d/$SITE-alert-tracks -chmod a+rx /etc/init.d/$SITE-alert-tracks +(su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:convert_init_script DEPLOY_USER='$UNIX_USER' VHOST_DIR='$DIRECTORY' SCRIPT_FILE=config/alert-tracks-debian.ugly" "$UNIX_USER") > /etc/init.d/"$SITE-alert-tracks" +chgrp "$UNIX_USER" /etc/init.d/"$SITE-alert-tracks" +chmod 754 /etc/init.d/"$SITE-alert-tracks" echo $DONE_MSG if [ $DEFAULT_SERVER = true ] && [ x != x$EC2_HOSTNAME ] |