How do I start a rails app after a deploy?

51 views
Skip to first unread message

Roy Miller

unread,
Mar 14, 2014, 3:12:57 PM3/14/14
to capis...@googlegroups.com
I'm running Cap 3.1.0, Rails 4.0.3, Ruby 2.1.0 on a Vagrant Virtual Box VM. My deploy is working fine, including the knife-solo provisioning of the machine. Now I need to finish things up by starting my Rails app in the deploy directory ... and I can't figure out how to do it. Google hasn't been any help so far. Makes me think I'm missing something truly basic.

I see this boilerplate in my deploy.rb:

after :publishing, :'start_cold'

desc 'Restart application'
task :restart do
  on roles(:app), in: :sequence, wait: 5 do
    execute :touch, release_path.join('tmp/restart.txt')
  end
end

Is that all that should be necessary to restart my Rails app? If so, it's not working. The server isn't running on the Vagrant box.

That led me down the path of trying to grep the ps aux output and see if there's a running ruby process, but I wonder if I'm making it way too hard. The basic question is, how do I start my Rails app after a deploy? Very soon after that, once I'm over that hump, I'll want to know how to restart it after a subsequent deploy. So feel free to kill two birds with one stone :)

Rob Hunter

unread,
Mar 15, 2014, 10:13:04 AM3/15/14
to capis...@googlegroups.com

Hi Roy,

In a typical deployment configuration, a Rails app is normally started by a Web server like Apache or Nginix.

If you have Apache running on the server, and you have configured it to serve a Rails app, then simply making a Web request will trigger mod_rack (aka Phusion Passenger) into spawning your Ruby app.

Phusion Passenger will also, under normal configuration, notice if the "restart.txt" file had been touched and do just what you would expect. That's why the boilerplate for restarting your app servers includes "touch tmp/restart.txt" - it's exactly what you want under this (quite common) configuration.

There are many other ways to run your app, but I don't want to overwhelm you with options if you're just getting started.

Good luck!

Hunter

--
You received this message because you are subscribed to the Google Groups "Capistrano" group.
To unsubscribe from this group and stop receiving emails from it, send an email to capistrano+...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/capistrano/9c735bae-e3bd-407e-b032-9cf5c98145b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lee Hambley

unread,
Mar 15, 2014, 10:39:12 AM3/15/14
to capistrano
I second Hunter's observations, mod_rack (Passenger) is a decent starting place for nginx and Apache. It's not the super-pro HA setup that some shops are running for zero-downtime restarts and extreme performance, but it's analogous to the Apache mod_php experience, of dropping files in the web root and letting Apache (or, it's modules) deal with it.

Roy Miller

unread,
Mar 15, 2014, 12:21:22 PM3/15/14
to capis...@googlegroups.com
Thanks, Rob and Lee.

I am indeed just getting started. Based on what I've read, Nginix + Passenger + Rails is a good combo, so I'll probably go with that. I did see the boilerplate restart task, and what you said about it makes perfect sense.

As an aside, Lee, you mentioned the "super-pro HA setup" folks are using for zero-downtime restarted and extreme performance. Can you share more details about that? I'll end up particularly interested in that soon.

Thanks again.

Roy

Lee Hambley

unread,
Mar 16, 2014, 5:23:38 AM3/16/14
to capistrano
As an aside, Lee, you mentioned the "super-pro HA setup" folks are using for zero-downtime restarted and extreme performance. Can you share more details about that? I'll end up particularly interested in that soon.

​Basically it boils down to using puma, or unicorn with the http://www.justinappears.com/blog/2-no-downtime-deploys-with-unicorn/ downtimeless restart on each node, and then using the appropriate parallelism helper to do a rolling restart https://github.com/capistrano/sshkit#parallel

​Also ​Roy, I don't know what it is about your emails, but *something* about them means I cant write a reply without deleting your side of the message in Gmail.​

Irish

unread,
Mar 17, 2014, 2:44:13 AM3/17/14
to capis...@googlegroups.com
You can get zero down time deploys (rolling restarts) with Passenger also, however it's in the paid "enterprise" edition only.
Reply all
Reply to author
Forward
0 new messages