How to start pm2 website using jenkins on AWS ubuntu server?

生来就可爱ヽ(ⅴ<●) 提交于 2020-07-09 03:48:08

问题


I set up Jenkins, pm2 on AWS ubuntu server. I had a website A that built by jenkins. The jenkins then will start that website by pm2 in the configured shell. However, only I start the website by logging on to the ubuntu server manually and run pm2 start A can make the website running.

The problem seems that pm2 started by user jenkins will not be visible by the outside world. Only started by user ubuntu (via ssh ubuntu@myubuntuserver) can be effectively public.

Why and how can I make jenkins start pm2 automatically?


回答1:


Actually the jenkins has already started pm2 automatically. Why you can't see it via pm2 status is because you logged in to the server with another user.

By sudo su jenkins you can switch to the jenkins user and then you can see them by pm2 status.




回答2:


Its late but just help someone in need:

Issue: pm2 would have been installed with ubuntu user or root, which Jenkins can't access

  • Login to Jenkins: sudo su jenkins (if password is required, set password from root user sudo passwd jenkins)
  • Install PM2: npm i -g pm2

Now, Jenkins should be able to run pm2



来源:https://stackoverflow.com/questions/36882267/how-to-start-pm2-website-using-jenkins-on-aws-ubuntu-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!