Tasks & AH Shutdown

31 views
Skip to first unread message

huytar...@gmail.com

unread,
Apr 29, 2015, 6:36:28 PM4/29/15
to action...@googlegroups.com
Hi All,

Question:

What can I do to help maintain a graceful-shutdown?


Background story:

I am spawning non-recurring tasks to retrieve information from, say, accuweather (relying on caching, fetches are infrequent).

After we have launched tasks, I have observed that we're hitting the 30 sec timeout in start.js when actionhero attempts to shutdown.

I imagine that I might have missed a step in the configuration dance somewhere along the way. As a temporary workaround, I've setup an initializer to remove tasks explicitly with api.tasks.del().

If we use api.tasks.del(), the worker's don't seem to get cleaned at the end. Instead, they are cleaned up after actionhero starts again - which will be fine in the short term.



Any guidance or education on the matter would greatly be appreciated.

Thanks in advance,
Huy.

Evan Tahler

unread,
Apr 30, 2015, 5:29:17 AM4/30/15
to action...@googlegroups.com, huytar...@gmail.com
You can configure that 30 second timeout via process.env.ACTIONHERO_SHUTDOWN_TIMEOUT, which you can set on the command line or as an environment variale.  There might be a bug there (we weren't enforcing it to be an integer) which would be updated here https://github.com/evantahler/actionhero/commit/841ebb8d300d18d5607cbc99f27e390b07f3c0d3

You can also see that the start script is quite tiny, and you can always wrap the actionhero prototype and create your own launcher. There are some docs about that here http://www.actionherojs.com/docs/ops/running-actionhero.html#programatic-use-of-actionhero
Message has been deleted

huytar...@gmail.com

unread,
Apr 30, 2015, 2:15:34 PM4/30/15
to action...@googlegroups.com, huytar...@gmail.com
Thanks, that will help.


In your experience (obviously as the author) - is it common for tasks to cause actionhero to rely on the graceful shutdown timeout?

Evan Tahler

unread,
Apr 30, 2015, 3:39:04 PM4/30/15
to action...@googlegroups.com, huytar...@gmail.com
Well, everything takes *some time* to stop, even the web server.  We allow actions in process to finish, tasks in process to finish etc.  You can demo this with an action that has a setTimeout(31) vs setTimeout(29) in it.    That said, when I personally have a task that takes loner than 30s, I break it up into lots of little tasks, so I don't have this problem... it also makes debugging easier.   
Reply all
Reply to author
Forward
0 new messages