node servers, npm scripts, spark2 and monit

107 views
Skip to first unread message

Naitik Shah

unread,
Dec 2, 2010, 11:48:32 PM12/2/10
to nodejs
In writing some server apps, and I'm trying to come up with a simple
system to manage the servers. I think ideally this would use npm
scripts to hide away details. This means "npm [start|stop|restart]
myapp" should be the public API. Ideally the thing behind the scenes
is just another node script. I think it's probably also fine to
require bash (and so require cygwin on windows). Currently I'm using
spark2 (https://github.com/davglass/spark2) to manage the servers,
and it's really nice and would be ideal to hook the two up. I haven't
figured out how to make "npm start" kick off a daemon process using
spark2, and have only been able to manage a foreground process so far.
Has anyone tried to do this yet?

The second part is some monitoring. I've come across Forever (https://
github.com/indexzero/forever) which seems nice, but I haven't tried it
yet. I'm already using monit (http://mmonit.com/monit/) for a number
of things (nginx frontend for one), and think ideally a non node
process doing the monitoring will help prevent node level issues from
killing everything. I think if "npm start myapp" works, then this
should be easy and just need something like:

check host myapp with address 127.0.0.1
start program = "npm start myapp"
stop program = "npm stop myapp"
if failed port 43600 protocol HTTP
request /
with timeout 10 seconds
then restart

Isaac Schlueter

unread,
Dec 3, 2010, 3:31:43 PM12/3/10
to nod...@googlegroups.com
Tying npm's stop/start in with the OS scheduling is on the todo
list[1], but certainly not trivial. Especially when there are such
great tools like Monit and Upstart in Linux, and SMF in Solaris, it
would be a bit silly to try to go through the trouble of trying to
reproduce all that those tools do.

I'd be interested in the results of your explorations there.

--i

1: https://github.com/isaacs/npm/issues/issue/117

> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
>

Ricardo Lanziano

unread,
Dec 7, 2010, 6:26:04 PM12/7/10
to nod...@googlegroups.com

On Dec 3, 2010, at 3:31 PM, Isaac Schlueter wrote:

> Tying npm's stop/start in with the OS scheduling is on the todo
> list[1], but certainly not trivial. Especially when there are such
> great tools like Monit and Upstart in Linux, and SMF in Solaris, it
> would be a bit silly to try to go through the trouble of trying to
> reproduce all that those tools do.
>
> I'd be interested in the results of your explorations there.

Thats exactly the same reason why I didn't choose spark2 nor monit.

I use Solaris SMF for managing all my apps, using spark for spawning
the different childrens. Using the operating systems facility for
managing services can reduce your app dependencies and tools.

--
Ricardo Lanziano
6838 E880 7CA4 D4B6 8283 8F65 96AD EC0B F113 AB62
To iterate is human, to recurse, divine.

Reply all
Reply to author
Forward
0 new messages