brettu
brettu

Reputation: 477

Can Capistrano notify me if Unicorn fails to start new processes

My Unicorn story: I deploy, the deployment fails (stacks or something else), the response is deployment complete, I have no idea the code served is the correct code unless I look at the logs. Even if look at the logs I have to be watching when Unicorn switches processes.

I start a Unicorn it launches pid=A pid=A forks to B,C,D,E

A is master

when I signal A with a USR2

it forks itself onces more (F)

NORMALLY

BUT... If the code deployed stacks - the application cannot start

The deployment failed, and the new code is on the server with the old processes running. This means the site hasn't changed. Capistrano give me the 'all good' sign.

I can see that the deployment fails in the logs # app/shared/log/unicorn.rc.log

forked child re-executing...
I, [2013-05-24T22:35:16.986618 #88700]  INFO -- : inherited addr=0.0.0.0:51020 fd=10
I, [2013-05-24T22:35:16.987264 #88700]  INFO -- : Refreshing Gem list
/u/app/releases/20130524223245/app/controllers/application_controller.rb:2: "This  application is deployed correctly" (RuntimeError)

I'm trying to get a solution in my deploy script, or my logs, which tells my developers the deploy failed when the Unicorn rolls back to the old process (ie... doesn't start running F) They need to be notified as a command line response so they don't have to open the logs.

Has anyone encountered how to communicate to your team if the new Unicorn process (F) doesn't become the new master for the application?

Upvotes: 4

Views: 278

Answers (1)

Litmus
Litmus

Reputation: 10996

Consider using a process monitoring tool such as God, Bluepill, monit etc. You can then issue USR2 through these tools in your capistrano deploy recipe. These can notify (in several ways) on process failure irrespective of the cause of failure (failed deployment or something else). They can also be configured to attempt restarting a failed process automatically.

Upvotes: 0

Related Questions