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.
Related
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
I am installing an SailsJS app on an Amazon Ubuntu instance.
If I run the app with sails lift everything works and the program run successfully. Now I try to run it through forever for obvious reasons. As specified by the SailsJS documentation I run forever on the app.js file located at the root of my project : forever start app.js
But that time the app fails :
forever list
info: Forever processes running
data: uid command script forever pid id logfile uptime
data: [0] XXXX /usr/bin/nodejs app.js 15348 15350 /home/ubuntu/.forever/XXXX.log STOPPED
Logfile contains only :
error: Forever detected script exited with code: 0
Any idea why sails lift would work but not with forever ?
Sometimes there are permissions errors. Try to verify forver's permissions files in .forever directory or maybe run with sudo.
I run forever start app.js with sudo and I did't have any problems.
After that sudo forever list a get:
data: [0] kBdX /usr/bin/nodejs app.js 23533 23538 /home/ubuntu/.forever/kBdX.log 0:0:34:28.312
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.
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?
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