forever start automatic.js error - node.js

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

Related

ForeverJS bash script errors on first line

Im trying to get a foreverJS script to run a Node server on an EC2 instance. The script looks like:
#!/bin/bash
forever stopall
forever hakuna-matata store in appropriate logs start 'full/qualified path'
Even if I add an echo "getting here" statement as the first line I still get an error. I do not know bash scripting well, so it may be permissions, relative/absolute path, EC2/node, environment variable related, but I honestly do not know.
Stacktrace:
[ec2-user#12-34-56 folder]$ forever startup.sh
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
/home/user/var/www/folder/startup.sh:2
echo "gh"
^^^^
SyntaxError: Unexpected string
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:533:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
error: Forever detected script exited with code: 1
I also tried via running the script via the forever service script with forever start startup.sh and get the same error. I've launched from the parent direct and with a (qualified) path.
whoami - user
which forever - /usr/local/bin/forever
which npm - /usr/local/bin/npm
sudo whomai - root
sudo which npm - /usr/bin/npm
sudo which forever - /usr/bin/forever
node -v -v8.2.1
npm -v - 5.3.0
Ask if you need additional environmental information...
Forever assumes SCRIPT is a JS file that can be executed with Node.js You're trying to run a bash script instead, so it errors out since echo "getting here" obviously isn't valid JS code.
To fix this, you need to use the -c command line option when running forever. From the docs:
-c COMMAND COMMAND to execute (defaults to node)
So in your case, you'd set -c to /bin/bash; like this:
forever start [LOG OPTIONS] -c /bin/bash path/to/your-shell-script.sh

nodejs(forever) "ENOSPC"

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

trouble in sails lift on AWS server

when I am running the project with sails lift then it shows -
Aborted due to warnings.
Running "sails-linker:devTpl" (sails-linker) task
padding length 4
Warning: Unable to write "views/layout.ejs" file (Error code: EACCES).
------------------------------------------------------------------------
error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `/var/myproj/.tmp` ?
error:
error: If you think this might be the case, try running:
error: sudo chown -R 1000 /var/myproj/.tmp
I have tried all the given steps like provide access to .tmp and npm install
and when I am debugging the code by sails debus is shows :
Grunt :: Error: listen EADDRINUSE :::5858
at Object.exports._errnoException (util.js:860:11)
at exports._exceptionWithHostPort (util.js:883:20)
at Agent.Server._listen2 (net.js:1234:14)
at listen (net.js:1270:10)
at Agent.Server.listen (net.js:1366:5)
at Object.start (_debug_agent.js:21:9)
at startup (node.js:72:9)
at node.js:972:3
Strange part is its running on my local system and on normal(other) server very fine and correctly working.
You'll need to chmod the views directory

foreverjs turns process in STOPPED state instead of restarting

I have nodejs process that listens for an connection. I want to let foreverjs restart it on any connection error this way:
amqpConnection.on('error', function (err) {
console.error(err);
process.exit(1);
});
But this don't work. After error I see my process in this state:
~> forever list
info: Forever processes running
data: uid command script logfile
data: [0] OpQF /usr/bin/node my-script.js my-script-log.log STOPPED
Log file has connection error and two attempts to restart script.
error: Script restart attempt #2
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect' }
error: Forever detected script exited with code: 1
Why forever stops trying to restart my process?
I should have read warnings that forever prints!
Script that not stay running more than --minUptime (1000ms by default) considered "spinning". One should set --spinSleepTime to make spinning scripts to be restarted. When this parameter is omitted spinning script won't be restarted.
I have reproduced your problem and found that forever successfully restart your process if some delay (1sec) take place before process.exit.
It's look that forever don't restart process when it crash too fast.
setTimeout(function() {
process.exit(1);
}, 1000);

NodeJS Forever package minUptime and spinSleepTime warnings

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

Resources