Seeking a solid startup script for node.js/forever

Jim Long james at umpquanet.com
Fri Mar 18 21:54:11 UTC 2016


Sigh.  I should test before I post.

The fix below is not sufficient.  It "mostly works" from inside the jail:

jailname : 14:44:06 /# service iws stop
jailname : 14:44:17 /# service iws start
jailname : 14:44:19 /# warn:    --minUptime not set. Defaulting to: 1000ms
warn:    --spinSleepTime not set. Your script will exit if it does not stay up for at least 1000ms
info:    Forever processing file: /usr/local/IWS4/app.js

But it doesn't work from outside the jail.  "service jail start" doesn't return to a shell prompt
unless I hit Ctrl-C.

hostname : 14:44:41 /root# service jail stop
Stopping jails: jailname
hostname : 14:44:45 /root# time service jail start
Starting jails:
load: 0.13  cmd: node 25865 [uwait] 94.17r 0.23u 0.03s 0% 33028k
^C

real    1m41.749s
user    0m0.010s
sys     0m0.017s

hostname : 14:44:23 /root#


On Fri, Mar 18, 2016 at 02:37:35PM -0700, Jim Long wrote:
> On Fri, Mar 18, 2016 at 12:36:03PM -0700, Jim Long wrote:
> > How can I modify this script so that it will start cleanly in the
> > background?
> 
> I guess the obvious, brute force solution is:
> 
> --- iws.orig    2016-03-18 14:35:21.206449824 -0700
> +++ iws 2016-03-18 14:33:39.770357734 -0700
> @@ -31,7 +31,7 @@
>  start()
>  {
>    NODE_ENV=production
> -  su -m www -c "exec ${forever} start -a -l ${HOME}/forever.log -o ${HOME}/output.log -e ${HOME}/error.log -p /var/run/forever ${script}"
> +  su -m www -c "exec ${forever} start -a -l ${HOME}/forever.log -o ${HOME}/output.log -e ${HOME}/error.log -p /var/run/forever ${script}" &
>  }
>  
>  status()
> 
> 
> but if anyone has something more elegant, I'd be grateful to learn of it.
> 
> Jim


More information about the freebsd-questions mailing list