Github Action Deployment to Cpanel for Nodejs Apps
Hello all,
I've scenario as follow.
1. Push Local Git repo to Github.
2. Github action runs deployment to cPanel via uAPI.
3. cPanel pull repo from Github
4. cPanel run .cpanel.yml which is :
Any suggestion to achieve my scenario?
- find PID of current running node apps.
- kill by its PID
- run npm start
deployment:
tasks:
- /bin/kill -9 $(ps -ef | egrep -i api.sayap.co.id | egrep -i server.js |awk {'print'}) 2> /dev/null
Any suggestion to achieve my scenario?
-
Hey there! I think there may be two issues happening here. The first issue is that you likely do not have the correct entries in the cpanel.yml file. Do you have the first line of "---" in the file? The second issue is that your "ps" command is getting the "illegal" output because it shows many processes that aren't controlled by that user. Can you run that command as the user over SSH outside of Git? I'm guessing you'll also get errors there. I'm wondering if these tools would be better handled in a Bash script as part of a Cron job, as adding Git to this type of work just seems to add another layer of confusion. 0 -
Hi cPRex, Thank you. The .cpanel.yml actually valid, sorry for not include that dash. --- deployment: tasks: - /bin/kill -9 $(ps -ef | egrep -i api.sayap.co.id | egrep -i server.js |awk {'print'}) 2> /dev/null
for ps, I can execute it over ssh and result with no errors. Yeah you right. Just trying with bash script. Here is my currently .cpanel.yml--- deployment: tasks: - cd /home/user/my-repo-path/ - git fetch && git pull - /bin/bash ../mssadewa.sh > /dev/null
Here is the mssadewa.sh#!/bin/bash /bin/kill -9 $(ps -ef | egrep -i api.sayap.co.id | egrep -i server.js |awk {'print'}) 2> /dev/null source /home/user/nodevenv/api.sayap.co.id/16/bin/activate && cd /home/user/api.sayap.co.id npm i && npm start &
with above setup, I got an polling iteration in github action. Any idea?0 -
I honestly don't have any other ideas about the Git side of things. If you'd like to make a ticket with our team (assuming you have root access to the server) we'd be happy to do some testing with that. 0 -
I honestly don't have any other ideas about the Git side of things. If you'd like to make a ticket with our team (assuming you have root access to the server) we'd be happy to do some testing with that.
Since I'm not the owner, I don't have root access. It's okay, I'll trying to get it work with another way. btw somehow I find you replay mentioning nodejs autostart and register it in application manager0
Please sign in to leave a comment.
Comments
4 comments