From owner-freebsd-questions@freebsd.org Fri Mar 18 21:54:11 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7446CAD5310 for ; Fri, 18 Mar 2016 21:54:11 +0000 (UTC) (envelope-from james@umpquanet.com) Received: from ns.umpquanet.com (ns.umpquanet.com [98.158.10.80]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5A9821885 for ; Fri, 18 Mar 2016 21:54:11 +0000 (UTC) (envelope-from james@umpquanet.com) Received: from ns.umpquanet.com (localhost [127.0.0.1]) by ns.umpquanet.com (8.14.9/8.14.9) with ESMTP id u2ILsAHf046796 for ; Fri, 18 Mar 2016 14:54:10 -0700 (PDT) (envelope-from james@ns.umpquanet.com) Received: (from james@localhost) by ns.umpquanet.com (8.14.9/8.14.9/Submit) id u2ILsA4H046795 for freebsd-questions@freebsd.org; Fri, 18 Mar 2016 14:54:10 -0700 (PDT) (envelope-from james@ns.umpquanet.com) Date: Fri, 18 Mar 2016 14:54:10 -0700 From: Jim Long To: freebsd-questions@freebsd.org Subject: Re: Seeking a solid startup script for node.js/forever Message-ID: <20160318215410.GA45558@ns.umpquanet.com> References: <20160318193603.GA20566@ns.umpquanet.com> <20160318213735.GA43466@ns.umpquanet.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160318213735.GA43466@ns.umpquanet.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Mar 2016 21:54:11 -0000 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