简体   繁体   中英

pm2 not starting server on elastic beanstalk

I am running into an issue. I have deployed my nodejs websocket app to Amazon elastic beanstalk. I am trying to run app as daemon process, that's why I have globally installed pm2 using configfile in ebextension:

container_commands:

01_node_symlink:    
  command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
02_npm_symlink:     
  command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"   
03_pm2_install:     
  command: "if [ ! -e /bin/pm2 ]; then npm install pm2 -g; fi"
  ignoreErrors: true 

As elastic beanstalk start server automatically, to use pm2 I have written start command in my package.js

start:"pm2 start server.js -i 0 --name="hub""

But when elastic beanstalk uses this command to start server it goes in start-stop loop and all cpus is used. Thanks in advance

That's because pm2 process exits just after it starts the server, so eb run it again. add " && pm2 logs" to the command to keep it on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM