I have problem with forever. My script was stopped. I can't run it by:
forever start 1
I recived:
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: 1
error: Cannot start forever
error: script /root/1 does not exist.
I tried to run it again by:
forever start forever.json
Forever.json:
{
"uid": "roulette",
"append": true,
"watch": true,
"script": "index.js",
"sourceDir": "/home/user/domains/roulette/node/",
"logFile": "/home/user/domains/roulette/logs/forever.log",
"outFile": "/home/user/domains/roulette/logs/out.log",
"errFile": "/home/user/domains/roulette/logs/err.log",
"command": "node --expose-gc"
}
I found in log:
events.js:154
throw er; // Unhandled 'error' event
^
Error: watch /home/user/domains/roulette/node/node_modules/socket.io-adapter/node_modules/socket.io-parser/bench/index.js ENOSPC
at exports._errnoException (util.js:856:11)
at FSWatcher.start (fs.js:1313:19)
at Object.fs.watch (fs.js:1341:11)
at createFsWatchInstance (/usr/lib/node_modules/forever/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/usr/lib/node_modules/forever/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/usr/lib/node_modules/forever/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleFile (/usr/lib/node_modules/forever/node_modules/chokidar/lib/nodefs-handler.js:255:21)
at FSWatcher.<anonymous> (/usr/lib/node_modules/forever/node_modules/chokidar/lib/nodefs-handler.js:473:21)
at FSReqWrap.oncomplete (fs.js:82:15)
I set my /tmp directory:
npm config set tmp /home/user/tmp
But after few days it crashed again. I have lot of space on drive.
Anyone know what's happened there?
Try nano-server instead lite-server
Thanks to Vrael
from Quickstart with Angular 2.0.0-beta.6 doesn't work
Related
I am trying to run nodemon on my local pc.
Even if i just run the command without parameters i get the following error:
events.js:182
throw er; // Unhandled 'error' event
^
Error: spawn cmd ENOENT
at _errnoException (util.js:1019:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:192:19)
at onErrorNT (internal/child_process.js:374:16)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
Turning on Verbose mode gives additional info along wiht this error:
[nodemon] Looking in package.json for nodemonConfig
[nodemon] 1.12.1
[nodemon] reading config C:\nodeprojects\myproject\package.json
[nodemon] to restart at any time, enter `rs`
[nodemon] ignoring: .git .nyc_output .sass-cache bower_components coverage C:\nodeprojects\myproject\node_modules/**/*
[nodemon] watching: *.*
[nodemon] watching extensions: js,json
[nodemon] starting `node app.js`
[nodemon] child pid: undefined
[nodemon] exiting
events.js:182
throw er; // Unhandled 'error' event
^
(Note - paths in above error altered to remove my username)
I have tried the basics, restarting my pc, checking if another app is using port 3000 (i dont think it is).
Any help or advice would be appreciated
Nodemon simply starts command "node app.js", if start node ok, it'll track files changes and restart node process.
Your error seems to cause by lack of nodejs configurations.
Try to check node program directory path is included in PATH variable or not.
In the windows pc, there're steps:
Find node install folder, commonly in C:\Program Files\nodejs or C:\Windows\System32\
Check this folder path in PATH variable value.
so i wanted to make the app running on openshift
i made an application and added the bitbucket url
(https://bitbucket.org/srabouin/backpack.tf-automatic)
its used to sell ingame items
so i open putty and do: cd app-root/runtime/repo/
then i type: node automatic.js
then it starts, but when i close putty, the app closes too...
its not made for openshift, so i saw maby you needed to edit the package.json file or something.
1) i would like to know what to change, or if you could change it for me
2) i use filezilla now to edit files and i think its working
i tryed to do this https://blog.openshift.com/run-your-nodejs-projects-on-openshift-in-two-simple-steps/
Could someone help me with forever?
i did: npm forever install
then: forever start automatic.js
[trading-kurryworst003.rhcloud.com repo]\> forever start automatic.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: automatic.js
fs.js:549
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT: no such file or directory, open '/var/lib/openshift/56d88d2e0c1e661d250000a9/.forever/_pTz.log'
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at Object.forever.startDaemon (/var/lib/openshift/56d88d2e0c1e661d250000a9/io-js/bin/iojs/lib/node_modules/forever/lib/forever.js:460:14)
at /var/lib/openshift/56d88d2e0c1e661d250000a9/io-js/bin/iojs/lib/node_modules/forever/lib/forever/cli.js:315:15
at /var/lib/openshift/56d88d2e0c1e661d250000a9/io-js/bin/iojs/lib/node_modules/forever/lib/forever/cli.js:161:5
at /var/lib/openshift/56d88d2e0c1e661d250000a9/io-js/bin/iojs/lib/node_modules/forever/lib/forever.js:412:11
at FSReqWrap.oncomplete (fs.js:82:15)
[trading-kurryworst003.rhcloud.com repo]\>
if i dont cd to app-root/runtime/repo
and i use forever start automatic.js i get:
[trading-kurryworst003.rhcloud.com 56d88d2e0c1e661d250000a9]\> forever start automatic.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: automatic.js
error: Cannot start forever
error: script /var/lib/openshift/56d88d2e0c1e661d250000a9/automatic.js does not exist.
also tryed screen but doesnt work
Trying to get a nodejs app up and running with pm2.
We use SASS and rebuild the to css files on file change with "node-sass-middleware". It all works perfectly until pm2 starts auto restarting the app every time the sass middleware rebuilds a css file... which, is what we tell it to do with:
pm2 start app.js --watch
So, after some reading of the docs it seems you are meant to be able to configure pm2 with a json file and it has an option of "ignore_watch".
So, following the guide on github: https://github.com/Unitech/PM2/blob/master/ADVANCED_README.md#json-app-declaration we set a config json file up to look as follows:
{
"name" : "ourApp",
"script" : "server.js",
"watch" : true,
"ignore_watch" : ["public/css"],
"env": {
"NODE_ENV": "development"
}
}
The problem is, as soon as we try to run it the pm2 logs spit out 1000's of lines of log errors all looking a little like this:
PM2: 2015-05-09 15:32:00: Error: watch ENOSPC
PM2: at errnoException (fs.js:1024:11)
PM2: at FSWatcher.start (fs.js:1056:11)
PM2: at Object.fs.watch (fs.js:1081:11)
PM2: at createFsWatchInstance (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:24:15)
PM2: at setFsWatchListener (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:47:19)
PM2: at EventEmitter.NodeFsHandler._watchWithNodeFs (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:177:15)
PM2: at EventEmitter.NodeFsHandler._handleFile (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:201:8)
PM2: at EventEmitter.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:353:12)
PM2: at Object.oncomplete (fs.js:107:15)
PM2: 2015-05-09 15:32:00: Error: watch ENOSPC
PM2: at errnoException (fs.js:1024:11)
PM2: at FSWatcher.start (fs.js:1056:11)
PM2: at Object.fs.watch (fs.js:1081:11)
PM2: at createFsWatchInstance (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:24:15)
PM2: at setFsWatchListener (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:47:19)
PM2: at EventEmitter.NodeFsHandler._watchWithNodeFs (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:177:15)
PM2: at EventEmitter.NodeFsHandler._handleFile (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:201:8)
PM2: at EventEmitter.<anonymous> (/usr/local/lib/node_modules/pm2/node_modules/chokidar/lib/nodefs-handler.js:353:12)
PM2: at Object.oncomplete (fs.js:107:15)
PM2: 2015-05-09 15:32:00: Process with pid 9155 still not killed, retrying...
PM2: 2015-05-09 15:32:00: Process with pid 9155 still alive after 800ms
thanks to the answer below
This seems to be the culprit and apparently in linux world ENOSPC means no disk space left.. but with only 2.1gig being used on the entire dev server with a total HDD space of 25gig this cannot be the issue.
PM2: 2015-05-09 15:32:00: Error: watch ENOSPC
Further more, when we run pm2 from cli as mentioned at the top is all works perfectly...
We really need this to work as it is causing havoc for the dev team.
Has anyone else hit this issue?
Thanks,
John
ENOSPC means no space left on the device. So check to see if one of your file systems is full. Assuming your on Linux or another Unix-like operating system, /tmp and /var are likely candidates.
I'm trying to run the forever function for node.js but I get below warnings;
C:\serv>forever start SERVER.js
warn: --minUptime not set. Defaulting to: 1000ms
warn: --spinSleepTime not set. Your script will exit if it does not stay up f
or at least 1000ms
info: Forever processing file: SERVER.js
How to set --minUptime and --spinSleepTime to remove these warnings
Installed forever package with npm install forever -g
These are only warnings. You could go on ignoring them, if you want.
But if you want to explicitly set them, forever --help tells you how to do so. Just start forever with:
forever start --minUptime 1000 --spinSleepTime 1000 SERVER.js
The documentation is not very exhaustive, a bit of additional information.
In the following examples we will use two scripts:
fail-fast.js:
process.exit(1);
fail-slow.js:
setTimeout(() => { process.exit(1); }, 2000);
1) using defaults
forever fail-fast.js
fail-fast.js script will execute only once, then no other start attempts will be made.
forever fail-slow.js
fail-slow.js script will be restarted indefinitely, as it stays up more than 1000ms (default value of minUptime if not specified). You can limit the number of restarts with the -m parameter.
2) setting only minUptime
forever --minUptime 10000 fail-fast.js
forever --minUptime 10000 fail-slow.js
Both fail-fast.js and fail-slow.js will be never be restarted, because we extended minUptime to 10 seconds and now fail-slow.js is considered spinning.
3) setting spinSleepTime
Whenever you set spinSleepTime (with or without minUptime), your process will restart even if it is considered 'spinning'.
forever --spinSleepTime 30000 fail-fast.js
forever --spinSleepTime 30000 fail-slow.js
Both scripts will be restarted forever, waiting spinSleepTime milliseconds between restarts.
In short:
When stop
if hadRunTime >= minUptime
restart
else if spinSleepTime != 0
wait spinSleepTime
restart
else
stop and no restart
#Megadix The answer has something wrong with spinSleepTime.
fail-fast.js will restart wating spinSleepTime,but fail-slow.js will restart immediately,no waiting! It can be Proved by:
console.log((new Date()).getTime());
setTimeout(() => {
process.exit(1);
}, 2000);
output like:
1468812185697
error: Forever detected script exited with code: 1
error: Script restart attempt #1
1468812187766
error: Forever detected script exited with code: 1
error: Script restart attempt #2
1468812189834
error: Forever detected script exited with code: 1
error: Script restart attempt #3
1468812191901
error: Forever detected script exited with code: 1
error: Script restart attempt #4
1468812193977
error: Forever detected script exited with code: 1
error: Script restart attempt #5
1468812196039
error: Forever detected script exited with code: 1
error: Script restart attempt #6
1468812198107
error: Forever detected script exited with code: 1
error: Script restart attempt #7
1468812200172
error: Forever detected script exited with code: 1
forever start --minUptime 1234 --spinSleepTime 3421 SERVER.js
https://github.com/nodejitsu/forever#usage
I'm assuming you are using express module that is way after you using - forever start SERVER.js - your server is not running, because express module run server in path ./bin/www - so you should use this command - forever start ./bin/www --name="SERVER" - name is the name of your js file, by default app.js
I have a node server running on AWS and I am using forever to keep it running in the background.
I have been very happy with forever so far; it's super easy to set up and use. However, even though my app is very simple, sometimes it crashes with this error:
Express server listening on port 3001
events.js:72
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
error: Forever detected script exited with code: 8
error: Forever restarting script for 4 time
When I look back at the logs, I can see that this has happened 4 more times, and each time forever manages to restart the server. However, when it happens for the 5th time, for some reason forever fails to restart the server and my app becomes unresponsive.
Express server listening on port 3001
events.js:72
throw er; // Unhandled 'error' event
^
Error: connect ECONNREFUSED
at errnoException (net.js:901:11)
at Object.afterConnect [as oncomplete] (net.js:892:19)
error: Forever detected script exited with code: 8
/usr/lib/node_modules/forever/node_modules/forever-monitor/node_modules/broadway/node_modules/eventemitter2/lib/ev$
throw arguments[1]; // Unhandled 'error' event
^
Error: Cannot stop process that is not running.
at /usr/lib/node_modules/forever/node_modules/forever-monitor/lib/forever-monitor/monitor.js:332:26
at process._tickCallback (node.js:415:13)
Has anyone else experienced similar problems?
You have to use the option -MAX like this:
forever -MAX 10000000000 Mypath/ToMyFile.js
Also put a -minUptime for the minimum time the server can stay up, if it crash before that laps of time then it won't go up again so set it to 1.
forever --minUptime (number-in-milisecond-here) -MAX (number-of-restart-here) path/file.js
Just try this:
forever --minUptime 1 -MAX 1000000000 YourPath/ToYourFile.js
More documentation there
https://www.npmjs.com/package/forever
To allow a max of 100 restarts when the server crashes
forever start -m 100 index.js