zapty / forever-service

Provision node script as a service via forever, allowing it to automatically start on boot, working across various Linux distros and OS
https://github.com/zapty/forever-service
MIT License
594 stars 65 forks source link

Please provide option to change the location of the LOGFILE #91

Open esimeon-hc opened 7 years ago

esimeon-hc commented 7 years ago

Hello, Hope all is well. Forever-service has been extremely useful for us. Would like to submit a request to be able to set the location for LOGFILE. Currently, it is hardcoded in initd.template line 34; LOGFILE="/var/log/{{service}}.log"

initd.template line 34; https://github.com/zapty/forever-service/blob/8ac17df6e94767d92352d5ae5eb62573a8ab1c0a/templates/sysvinit/initd.template

upstart.template 25: https://github.com/zapty/forever-service/blob/8ac17df6e94767d92352d5ae5eb62573a8ab1c0a/templates/upstart/upstart.template

I tried using the forever log option when I created the service: --foreverOptions " -l /appl/logs/myApp.log"

I got an interesting error:

path.js:7 throw new TypeError('Path must be a string. Received ' + inspect(path)); ^

TypeError: Path must be a string. Received [ '/var/log/myApp.log', '/appl/logs/myApp.log' ] at assertPath (path.js:7:11) at Object.join (path.js:1211:7) at Object.forever.logFilePath (/usr/lib/node_modules/forever/lib/forever.js:943:12) at tryStart (/usr/lib/node_modules/forever/lib/forever/cli.js:152:21) at /usr/lib/node_modules/forever/lib/forever/cli.js:318:5 at Array.forEach (native) at Object.app.cmd.cli.startDaemon (/usr/lib/node_modules/forever/lib/forever/cli.js:316:11) at apply (/usr/lib/node_modules/forever/node_modules/director/lib/director/router.js:448:19) at _every (/usr/lib/node_modules/forever/node_modules/director/lib/director/router.js:30:9) at Router.invoke (/usr/lib/node_modules/forever/node_modules/director/lib/director/router.js:454:5)

ChrisTalman commented 7 years ago

Unfortunately I can't help you with this, as I'm experiencing the same issue. The odd thing is, somehow I achieved it in the past, but that was a while ago while I was testing out forever-service, and I have since forgotten how it can be achieved.

The command that I have been using is as follows.

sudo forever-service install app -o " -o /path/to/file/out.log -e /path/to/file/err.log" --script app.js

Perhaps this can be of some help to you and others. Something like this should work, but something must be wrong with it in its current form.

LajosPolya commented 5 years ago

I looks a bit into the code and if you look at the templates directory you'll see that "/var/log" is hard coded, and that's where the log files will be stored.