Reputation: 5121
I'm trying to start a sails app with pm2, but i got the following error:
pm2 start app.js --name myapp -i 2
pm2 logs
[myapp-1 (out) 2014-05-25T13:38:51] info: Sails <|
[myapp-1 (out) 2014-05-25T13:38:51] info: v0.10.0-rc7 |\
[myapp-1 (out) 2014-05-25T13:38:51] info: /|.\
[myapp-1 (out) 2014-05-25T13:38:51] info: / || \
[myapp-1 (out) 2014-05-25T13:38:51] info: ,' |' \
[myapp-1 (out) 2014-05-25T13:38:51] info: .-'.-==|/_--'
[myapp-1 (out) 2014-05-25T13:38:51]
[myapp-1 (err) 2014-05-25T13:38:51] debug: Environment : development
[myapp-1 (err) 2014-05-25T13:38:51] debug: Port : 1338
[myapp-1 (err) 2014-05-25T13:38:51] debug: --------------------------------------------------------
[myapp-1 (err) 2014-05-25T13:38:51] TypeError: Object #<Object> has no method 'addAsyncListener'
[myapp-1 (err) 2014-05-25T13:38:51] at Server._listen2 (net.js:1095:18)
[myapp-1 (err) 2014-05-25T13:38:51] at cb (net.js:1139:10)
[myapp-1 (err) 2014-05-25T13:38:51] at rr (cluster.js:552:5)
[myapp-1 (err) 2014-05-25T13:38:51] at Worker.<anonymous> (cluster.js:484:9)
[myapp-1 (err) 2014-05-25T13:38:51] at process.<anonymous> (cluster.js:611:8)
[myapp-1 (err) 2014-05-25T13:38:51] at process.EventEmitter.emit (events.js:123:20)
[myapp-1 (err) 2014-05-25T13:38:51] at handleMessage (child_process.js:318:10)
[myapp-1 (err) 2014-05-25T13:38:51] at Pipe.channel.onread (child_process.js:346:11)
Sails version: 0.10.0-rc7
pm2 version: 0.8.6
Also, i don't know how to set the environment and port. I've tried with --node-args="--prod"
but had no effect.
I've tried with module forever and works fine.
Does anyone have any idea how I could fix this?
Thank you
Edit
Apparently is a problem with the version of node.js.
I did some tests and i reported the problem in the pm2 repository: https://github.com/Unitech/pm2/issues/491.
Any news i'll update here.
Upvotes: 0
Views: 3209
Reputation: 71
Does anyone have any idea how I could fix this?
Start pm2 like this:
pm2 start app.json
where app.json is:
{
"apps": [{
"name": "app",
"script": "/full/path/to/app.js",
"env": {
"NODE_ENV": "production"
}
}]
}
sails: v.0.11.0, pm2: v.0.12.7
Upvotes: 3
Reputation: 5971
--node-args
is for node V8 arguments, not for your script.
If you want to pass CLI arguments to your NodeJS script you must do
$ pm2 start app.js -- -prod
Every argument after the --
will be passed to your script.
Upvotes: 5
Reputation: 23340
Not sure about the addAsyncListener
error, but environment variables should work as normal. I've just confirmed this by test:
$ NODE_ENV=production pm2 start app.js
In logs:
[app-1 (out) 2014-05-25T15:27:04] in production environment
Upvotes: 3