Passenger keep-alive? (Disable passenger's auto shutdown) - passenger

I'm building a service which integrates within slack slash commands. Through the night, passenger automatically shuts down my rails application.
So the next day, the first request will result in a timeout, because passenger is still booting my app.
Is there any way to always keep the application running?
Note: I'm using mod_passenger not passenger standalone.

Either set a minimum number of instances to keep around with PassengerMinInstances or disable idle shutdown all together with PassengerPoolIdleTime

Related

How can I handle application cleanup on Phusion Passenger restarts?

I use Phusion Passenger + Apache to run various applications. At deployment time we take advantage of it's file based restart by touching <<app_dir>>/tmp/restart.txt.
One thing has always eluded me... what does Passenger do to the old process? I've been troubleshooting some cleanup tasks in one of our applications that don't seem to run when passenger stops the process.
The application traps SIGINT and SIGTERM signals so I'm guessing that Passenger isn't using either of them. Does anyone know for certain what passenger does to processes at restart or have experience with the same issue (application cleanup at Passenger restart)?
Any information, ideas, or thoughts would be appreciated.
Thanks,
Tim Birkett.

Heroku dyno automatic restart - are the stopped functions preserved?

I have two web dynos in my heroku app, and at times get a dyno automatic restart (as per heroku policy). Is the function that was going on during the restart automatically restored in the new restarted dyno? If not, is there a way I can control this restart?
Is the function that was going on during the restart automatically restored in the new restarted dyno?
no
If not, is there a way I can control this restart?
no
What you can do, is trap the SIGTERM signal that is sent to your process 10 seconds before it is SIGKILLed. This would give you time to finish current computation, stop taking web requests, do cleanup, etc. More details on the process is in the Heroku Devcenter.

Sinatra: Hot Code Pushes In Production?

When I push new code from my Sinatra application to my production server, I am currently triggering a restart of passenger by touching tmp/restart.txt, which loads the new changes. The problem is that the site is essentially down for about 10 seconds during this process.
How can I setup my server so that I can completely avoid any downtime?
That is, I want the application to keep serving the old version of the code until the new code is completely loaded, and then to instantly switch to the new code.
Using shotgun or sinatra/reloader will not work here since this is a production environment. Finally, if the answer depends on the application server, I'd be interested in how to do it with both unicorn and passenger.
What you're looking for is rolling restarts. Phusion Passenger Enterprise supports this: http://www.modrails.com/documentation/Users%20guide%20Nginx.html#PassengerRollingRestarts

How to set up a periodic nodeJS worker on Heroku Cedar

I've got an Express Web app running as my main app on Heroku Cedar. I need to run a worker job periodically. I know I can specify a worker: in my Procfile, but that seems to be for a forever running kind of job. Perhaps there is a way to have the event mechanism of nodeJS caus e the worker to Idle, and use Cron to poke it alive periodically??
to keep your process alive you can try using an external service which will "ping" your application, you can use the newrelice free addon on heroku for that.
I am currently experimenting and it seems that even with this the application is still put in idle mode but it restarts on the next "ping" so it is still up most of the time.
I don't known node.js but I do my worker with Ruby+EventMachine inside a ruby on rails application and it works fine, you just need something to work in the background aside of your web requests.

How can I run something in a thread with passenger?

I'm using Phusion Passenger with my nginx to deploy rails/sinatra applications, and I'm currently having a problem.
I want to run a class that checks for new submissions to reddit.com every 30 seconds. But since passenger shuts down the application after x seconds of idle time, it won't keep checking.
Yes, I've tried to set passenger_pool_idle_time to 0, but it still shuts it down.
If you want more details, see the application at github
Thanks in advance.
you could use cron to call into your server ever so often, to make sure it's still running. What may be happening is that passenger is starting up an initial process, then forking it for each worker process it needs later. After awhile, it kills the initial process (thinking it has spawned all the children it ever needs), so setting it to not do that might fix it.

Resources