Installation script should have an option to set up alaveteli for use with capistrano #1596

Open
crowbot opened this Issue Jun 13, 2014 · 10 comments

Comments

Projects
None yet
3 participants
@crowbot
Member

crowbot commented Jun 13, 2014

This means inserting the path element 'current' in various different places:

  • The apache config
  • The crontabs
  • The MTA config
  • The mail aliases file in the deployment directory

@crowbot crowbot added the 1 - new label Jun 13, 2014

@crowbot

This comment has been minimized.

Show comment
Hide comment
@crowbot

crowbot Jun 13, 2014

Member

Perhaps this should be done when a 'production mode' flag is set.

Member

crowbot commented Jun 13, 2014

Perhaps this should be done when a 'production mode' flag is set.

@crowbot

This comment has been minimized.

Show comment
Hide comment
@crowbot

crowbot Jun 13, 2014

Member

Or staging..

Member

crowbot commented Jun 13, 2014

Or staging..

@garethrees

This comment has been minimized.

Show comment
Hide comment
@garethrees

garethrees Jun 13, 2014

Member

FWIW I've had previous success using whenever to manage crontabs with capistrano.

Member

garethrees commented Jun 13, 2014

FWIW I've had previous success using whenever to manage crontabs with capistrano.

@crowbot

This comment has been minimized.

Show comment
Hide comment
@crowbot

crowbot Jun 13, 2014

Member

The main difference in deploying Alaveteli with Capistrano is that the app is served from a current directory - deploying a new version is essentially creating a timestamped sister directory to the current directory, and moving the symlink current from the old timestamped directory to the new one. Things that need to persist between deployments, like config files, are kept in a shared directory that is at the same level, and symlinked-to from each timestamped deploy directory.

In order to manually make a copy of alaveteli (installed on a server with the manual install instructions/installation script) work with capistrano, do this:

  • Set up capistrano on your local machine, editing the deploy.yml file so that the deploy_to path is the path where alaveteli is currently installed - if you used the installation script, this will be /var/www/alaveteli/alaveteli
  • Move the alaveteli app to a temporary place on the server, like your home directory
  • On your local machine, run cap -S stage=staging deploy:setup to setup capistrano on the server
  • Again on your local machine, run cap -S stage=staging deploy:update_code to get a code checkout on the server
  • Copy the following config files from the previous copy of alaveteli to the shared directory created by capistrano on the server:
    • general.yml
    • database.yml
    • rails_env.rb
    • newrelic.yml
    • aliases (If you're using Exim as your MTA)
  • If you're using Exim as your MTA, edit the aliases file you just copied across so that the path to alaveteli includes the current element. If it was /var/www/alaveteli/alaveteli/script/mailin, it should now be /var/www/alaveteli/alaveteli/current/script/mailin
  • Copy the following directories from the previous copy of alaveteli to the shared directory created by capistrano on the server:
    • cache/
    • files/
  • Run cap [-S stage=production] deploy on your local machine to create a deployment directory on the server
  • Update the webserver config (either apache or nginx) to add the current element to the path where it is serving alaveteli from. If you installed using the installation script, this will be replacing /var/www/alaveteli/alaveteli/ with /var/www/alaveteli/alaveteli/current in etc/nginx/sites-available/default
  • Edit the server crontab so that the paths in the cron jobs also include the current element. If you used the install script the crontab will be in etc/cron.d/alaveteli
  • Update the MTA config to include the current element in the paths it uses. If you installed using the installation script, the MTA will be postfix, and you will need to edit /etc/postfix/master.cf to replace argv=/var/www/alaveteli/alaveteli/script/mailin with argv=/var/www/alaveteli/alaveteli/current/script/mailin. If you're using Exim as your MTA, edit etc/exim4/conf.d/04_alaveteli_options to update the ALAVETELI_HOME variable to the new alaveteli path.
Member

crowbot commented Jun 13, 2014

The main difference in deploying Alaveteli with Capistrano is that the app is served from a current directory - deploying a new version is essentially creating a timestamped sister directory to the current directory, and moving the symlink current from the old timestamped directory to the new one. Things that need to persist between deployments, like config files, are kept in a shared directory that is at the same level, and symlinked-to from each timestamped deploy directory.

In order to manually make a copy of alaveteli (installed on a server with the manual install instructions/installation script) work with capistrano, do this:

  • Set up capistrano on your local machine, editing the deploy.yml file so that the deploy_to path is the path where alaveteli is currently installed - if you used the installation script, this will be /var/www/alaveteli/alaveteli
  • Move the alaveteli app to a temporary place on the server, like your home directory
  • On your local machine, run cap -S stage=staging deploy:setup to setup capistrano on the server
  • Again on your local machine, run cap -S stage=staging deploy:update_code to get a code checkout on the server
  • Copy the following config files from the previous copy of alaveteli to the shared directory created by capistrano on the server:
    • general.yml
    • database.yml
    • rails_env.rb
    • newrelic.yml
    • aliases (If you're using Exim as your MTA)
  • If you're using Exim as your MTA, edit the aliases file you just copied across so that the path to alaveteli includes the current element. If it was /var/www/alaveteli/alaveteli/script/mailin, it should now be /var/www/alaveteli/alaveteli/current/script/mailin
  • Copy the following directories from the previous copy of alaveteli to the shared directory created by capistrano on the server:
    • cache/
    • files/
  • Run cap [-S stage=production] deploy on your local machine to create a deployment directory on the server
  • Update the webserver config (either apache or nginx) to add the current element to the path where it is serving alaveteli from. If you installed using the installation script, this will be replacing /var/www/alaveteli/alaveteli/ with /var/www/alaveteli/alaveteli/current in etc/nginx/sites-available/default
  • Edit the server crontab so that the paths in the cron jobs also include the current element. If you used the install script the crontab will be in etc/cron.d/alaveteli
  • Update the MTA config to include the current element in the paths it uses. If you installed using the installation script, the MTA will be postfix, and you will need to edit /etc/postfix/master.cf to replace argv=/var/www/alaveteli/alaveteli/script/mailin with argv=/var/www/alaveteli/alaveteli/current/script/mailin. If you're using Exim as your MTA, edit etc/exim4/conf.d/04_alaveteli_options to update the ALAVETELI_HOME variable to the new alaveteli path.
@davewhiteland

This comment has been minimized.

Show comment
Hide comment
@davewhiteland

davewhiteland Jun 13, 2014

Contributor

we've pulled this text (and battered it into even more shape) back into the deploy page

Contributor

davewhiteland commented Jun 13, 2014

we've pulled this text (and battered it into even more shape) back into the deploy page

davewhiteland added a commit that referenced this issue Jun 13, 2014

fixes to comments/input from @crowbot
This includes the deploy/Capistrano instructions from #1596
@garethrees

This comment has been minimized.

Show comment
Hide comment
@garethrees

garethrees Jun 30, 2014

Member

Requires #1071

Member

garethrees commented Jun 30, 2014

Requires #1071

@crowbot

This comment has been minimized.

Show comment
Hide comment
@crowbot

crowbot Jul 1, 2014

Member

The vhost user generated by the install script needs to have a password so they can ssh to the host.

Member

crowbot commented Jul 1, 2014

The vhost user generated by the install script needs to have a password so they can ssh to the host.

@garethrees

This comment has been minimized.

Show comment
Hide comment
@garethrees

garethrees Jul 1, 2014

Member

The vhost user generated by the install script needs to have a password so they can ssh to the host.

It would be better to use SSH keys here, by adding people's public key to $USER/.ssh/authorized_keys.

Member

garethrees commented Jul 1, 2014

The vhost user generated by the install script needs to have a password so they can ssh to the host.

It would be better to use SSH keys here, by adding people's public key to $USER/.ssh/authorized_keys.

@crowbot

This comment has been minimized.

Show comment
Hide comment
@crowbot

crowbot Jul 8, 2014

Member

We should document the fact that the install script can be run in development or production mode and say what that means e.g. in production mode you get a sysvinit script for stopping and starting the alaveteli app server.

Member

crowbot commented Jul 8, 2014

We should document the fact that the install script can be run in development or production mode and say what that means e.g. in production mode you get a sysvinit script for stopping and starting the alaveteli app server.

@crowbot

This comment has been minimized.

Show comment
Hide comment
@crowbot

crowbot Jul 31, 2014

Member

Thin should probably be run as a cluster when installed in production mode.

Member

crowbot commented Jul 31, 2014

Thin should probably be run as a cluster when installed in production mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment