I'm attempting to do some continuous deployment of some rails micro-services on my ubuntu server, I'm thinking maybe runit would be a good idea to supervise these processes, then use migrations in chef to update the microservice - but I'm stuck getting one service to work. Basically the installation seems to work in the chef deploy but the app doesn't start and is not listening on 3000 ( doing a manual start from the deployment folder does work after killing the server.pid )
This is a cleanly provisioned machine and the only rails app on the box - so the error mentioned in the log I think is symptom of how I'm attempting to start it.
Any tips on how this might work (alternatives) appreciated!
Template
#!/bin/bash
set -e
exec chpst -u root:root nohup rails server &
It doesn't look like nohup is the way to do this - the log file produces this. I don't understand how a server is already running - the first log entry says its already running... however a
2015-10-14_22:15:24.87117 A server is already running. Check /opt/deploy/releases/39b30d7738bfba76462e257eb15100e1bea4edf0/tmp/pids/server.pid.
2015-10-14_22:15:25.32768 => Booting Thin
2015-10-14_22:15:25.32771 => Rails 4.2.0 application starting in development on http://localhost:3000
2015-10-14_22:15:25.32772 => Run `rails server -h` for more startup options
2015-10-14_22:15:25.32772 => Ctrl-C to shutdown server
2015-10-14_22:15:25.32773 Exiting
this repeats several times... until this error no longer logs.
2015-10-14_22:15:17.16187 A server is already running. Check /opt/deploy/releases/39b30d7738bfba76462e257eb15100e1bea4edf0/tmp/pids/server.pid.
2015-10-14_22:15:17.60398 => Booting Thin
2015-10-14_22:15:17.60401 => Rails 4.2.0 application starting in development on http://localhost:3000
2015-10-14_22:15:17.60402 => Run `rails server -h` for more startup options
2015-10-14_22:15:17.60403 => Ctrl-C to shutdown server
2015-10-14_22:15:17.60404 Exiting
if I ps aux | grep rails it l lots of these entries
root 17709 3.6 1.4 93692 29468 ? Rl 23:18 0:01 /usr/bin/ruby1.9.1 bin/rails server
root 17713 3.7 1.4 92112 28684 ? Rl 23:18 0:01 /usr/bin/ruby1.9.1 bin/rails server
root 17717 3.7 1.3 91844 27696 ? Rl 23:18 0:00 /usr/bin/ruby1.9.1 bin/rails server
root 17721 3.5 1.2 90164 26072 ? Rl 23:18 0:00 /usr/bin/ruby1.9.1 bin/rails server
root 17725 3.6 1.2 90164 26192 ? Rl 23:18 0:00 /usr/bin/ruby1.9.1 bin/rails server
Recipe
deploy_revision("/opt/deploy") do
revision "master"
repository "https://repo"
user "root"
action :deploy
shallow_clone true
keep_releases 3
rollback_on_error true # remove release if callbacks failed
migrate true
migration_command "rake db:migrate"
before_migrate do
execute "bundle install" do
command "bundle install"
cwd "#{release_path}"
user "root"
end
end
symlink_before_migrate.clear
create_dirs_before_symlink.clear
purge_before_symlink.clear
symlinks.clear
end
runit_service "auth" do
run_template_name "myapp"
log_template_name "myapp"
options({
:app_env => "development",
:app_home => "/opt/deploy/current",
:data_dir => "/opt/deploy/data"
})
retries 3
retry_delay 5
end