Report this

What is the reason for this report?

How do I run a bash command when Unicorn starts up on rails?

Posted on July 20, 2015

I’m currently working on an instance with a Rails server with Unicorn on Ubuntu. I’ve gotten everything running, except for one thing.

There is a gem I’m using called delayed jobs, and it needs to start as a daemon to function correctly whenever the server restarts. The problem is that it seems like the gem has very many different ways of starting, many of which aren’t supported with my current version. So, I thought instead of searching through piles of inapplicable docs, I could just start it up with a shell command that I know works.

I’m not using anything like Capistrano - so what would the best way of running a command-line script when Unicorn starts be? I have to run

cd /home/rails/ 
RAILS_ENV=production bin/delayed_job start

Thanks.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.