nodejs forever: File config.json not found or is invalid - linux

I have strange problem with nodejs forever.
I have cloned iodocs to /home/user/iodocs
If I start forever from iodocs directory:
user#ubuntu:~/iodocs$ forever start app.js
everything is working fine.
If I try start forever from another directory, for example:
user#ubuntu:~$ forever start --sourceDir /home/user/iodocs/ app.js
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: app.js
In log file I have seen:
user#ubuntu:~$ forever logs
info: Logs for running Forever processes
data: script logfile
data: [0] /home/user/iodocs/app.js /home/user/.forever/xYBf.log
user#ubuntu:~$ cat /home/user/.forever/xYBf.log
File /home/user/config.json not found or is invalid. Try: `cp config.json.sample config.json`
error: Forever detected script exited with code: 1
Why forever try to read config from unix user home directory instead sourceDir?
How to fix it?

Related

Nodejs forever pm

I am using a forever PM for my nodejs API.
I'm getting the following error while i try to start the app using forever.
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: hello.js
error: Cannot start forever
error: log file /home/user/.forever/forever.log exists. Use the -a or --append option to append log.
user#testub002:~$
Thanks in advance.
It seems your problem is that you need to either delete /home/user/.forever/forever.log each time you run forever or execute forever -a hello.js

Forever dont want to start

I learning NodeJS. I have ubuntu 16 server with installed nodejs. Then i install globally express-generator and forever. Next i maked a folder into /var/www named as hack-it-up.ru and used express-generator to generate the app. Next i changed port of my app as 8081 and tryed to start it with npm start. All works fine. But... when i tryed to start my app with forever, i got errors. I readed lots of guides but didnt solved it. Help me please. Thanks!
root#ashipka:/var/www/hack-it-up.ru# forever start -l /var/www/forever-logs/hack-it.log -a app.js
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: app.js
root#ashipka:/var/www/hack-it-up.ru# forever list
info: Forever processes running
data: uid command script forever pid id logfile uptime
data: [0] aj4I /usr/local/bin/node app.js 27060 27066 /root/.forever/aj4I.log STOPPED
data: [1] wFf4 /usr/local/bin/node app.js 27147 27153 /var/www/forever-logs/hack-it.log STOPPED
root#ashipka:/var/www/hack-it-up.ru# forever stop 0
error: Forever cannot find process with id: 0
I needed to start from bin/www file instead of app.js as said Mohit Bhardwaj. Thanks! All works fine.

error: Forever detected script exited with code: 0

I have a simple script to watch change in file,
index.js
var watch = require('node-watch');
watch('C:\CRM\log.txt', function(filename) {
console.log(filename, ' changed.');
});
I am trying to run it via command
forever start index.js
Its showing output:
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: index.js
and the control is returning to command prompt, instead of staying there! How can I keep it running and get the console.log output as soon as file is changed?
forever start index.js will start up in the background. From the sounds of it, you want it to stay in the foreground. Use forever index.js instead.

Forever not working with sailsjs

I've installed forever using
npm install forever -g
I've set config in modeljs to safe
migrate: 'safe'
Still when I run
forever -w start app.js
I get this
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: app.js
I dont want to stop and start my app using sails lift everytime I'm making a change. I'm using sails version of 0.11.
Used sails-hook-autoreload in the end which did the same job with ease.

nodejs + nodemon + forever give me an error

I just installed forever globally (-g). Before that I used to run with
$ npm start
Now after installed forever, I tried to lunch the node app
$ NODE_ENV=development forever nodemon server.js
but I receive this error
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
error: Cannot start forever
error: script /path/to/app/nodemon does not exist.
the same also with
$ NODE_ENV=development forever nodemon server.js
any idea?
The error you received in your output:
error: script /path/to/app/nodemon does not exist.
It appears that forever is looking for nodemon in the current working directory, and can't find it because it doesn't exist there. Try providing the absolute path when starting nodemon, which can be found with which nodemon.
forever start /usr/local/bin/nodemon server.js
Note that the start flag is what puts the application in daemon mode.
Try this
NODE_ENV=development forever start -c nodemon server.js
The -c is for execute commands, forever send you that error because it's looking for a app called nodeamon, but your app is server.js

Resources