pm2
pm2 copied to clipboard
PM2 reload <name> not being executed via github actions
I am using github action to create a pipeline and using pm2 as the process manager.
pm2 reload server
When I run the above command locally the process is reloaded. When run it through action runner by running the bash command provided by github action that is - ./svc.sh
I get the following error:
0s Run pm2 restart server /actions-runner/_work/_temp/d8a0a9e1-465d-49aa-a242-6d80da54584f.sh: line 1: pm2: command not found Error: Process completed with exit code 127.
However When I run it through ./run.sh the sequence of action including run pm2 reload server
executes successfully.
Node: 12.X Pm2: 4.5.4
i got exact same error! i have not found a solution.
Hi what is your solution?
On Sat, Apr 24, 2021, 12:17 PM cheseren @.***> wrote:
i got exact same error! i have not found a solution.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Unitech/pm2/issues/4989#issuecomment-826043864, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFUYD6OLQMEBY362GJ7TTTLTKJQYBANCNFSM4XQMR56Q .
To anyone who facing the same issue, the problem was is that yarn global bin path wasn't added in actions-runner .path
file, so it simply wasn't able to run it.
Added :/home/ubuntu/.yarn/bin
to the end of default path and restarted svc.sh solved the issue.
Had the same issue, running the svc.sh with sudo fixed it. Resinstall the service with sudo ./svc.sh install
and start it.
Had the same issue, running the svc.sh with sudo fixed it. Resinstall the service with
sudo ./svc.sh install
and start it.
It worked for me! Thanks.
maybe duplicate https://github.com/Unitech/pm2/issues/1112
in my case in github actions $PATH env did not match server side (there was no path to npm folder)
the following helped me:
connected to the server and entered npm config get prefix
got the following path: /home/ubuntu/.nvm/versions/node/v12.17.0
Then I just wrote the following code at the beginning of the ssh connection script (I use appleboy/ssh-action):
export PATH=$PATH:/home/ubuntu/.nvm/versions/node/v12.17.0/bin
(also remember to add /bin
)
after these actions, pm2 worked for me
can also help: https://stackoverflow.com/a/41317809/15601487 https://stackoverflow.com/a/65477541/15601487
@JoCat this helped get pm2
running on my server. The output from npm config get prefix
was completely different, but I used that and followed your way. Everything's working now. Thx.
Had the same issue, running the svc.sh with sudo fixed it. Resinstall the service with
sudo ./svc.sh install
and start it.
Worked For me Thank you saved my day
In ~/.bashrc
comment line with return, and now all ssh will be interactively
# If not running interactively, don't do anything
case $- in
*i*) ;;
#*) return;;
esac
And another solution
name: Deploy latest version
on:
push:
branches:
- production
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
deploy:
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Create SSH key
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519
sudo chmod 600 ~/.ssh/id_ed25519
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts2
shell: bash
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY_PROD }}
SSH_KNOWN_HOSTS: ${{ vars.KNOWN_HOSTS }}
# - name: Test SSH key
# run: ssh -vT ${{ vars.EC2_USERNAME }}@${{ vars.EC2_HOST }} -p ${{ vars.EC2_HOST_PORT }}
# Runs a single command using the runners shell
- name: Make git pull
run: |
ssh ${{ vars.EC2_USERNAME }}@${{ vars.EC2_HOST }} -p ${{ vars.EC2_HOST_PORT }} '
cd ./${{ github.event.repository.name }};
git pull
'
- name: pm2 restart
run: |
ssh ${{ vars.EC2_USERNAME }}@${{ vars.EC2_HOST }} -p ${{ vars.EC2_HOST_PORT }} '
export PATH=$PATH:/home/ubuntu/.nvm/versions/node/v18.13.0/bin;
pm2 restart ${{ github.event.repository.name }} --update-env
'
In
~/.bashrc
comment line with return, and now all ssh will be interactively# If not running interactively, don't do anything case $- in *i*) ;; #*) return;; esac
And another solution
name: Deploy latest version on: push: branches: - production workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: deploy: runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Create SSH key run: | mkdir -p ~/.ssh/ echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_ed25519 sudo chmod 600 ~/.ssh/id_ed25519 echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts2 shell: bash env: SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY_PROD }} SSH_KNOWN_HOSTS: ${{ vars.KNOWN_HOSTS }} # - name: Test SSH key # run: ssh -vT ${{ vars.EC2_USERNAME }}@${{ vars.EC2_HOST }} -p ${{ vars.EC2_HOST_PORT }} # Runs a single command using the runners shell - name: Make git pull run: | ssh ${{ vars.EC2_USERNAME }}@${{ vars.EC2_HOST }} -p ${{ vars.EC2_HOST_PORT }} ' cd ./${{ github.event.repository.name }}; git pull ' - name: pm2 restart run: | ssh ${{ vars.EC2_USERNAME }}@${{ vars.EC2_HOST }} -p ${{ vars.EC2_HOST_PORT }} ' export PATH=$PATH:/home/ubuntu/.nvm/versions/node/v18.13.0/bin; pm2 restart ${{ github.event.repository.name }} --update-env '
This is working , thanks