ssh-action
ssh-action copied to clipboard
why I get an error :"Process exited with status 1"
the result is:
======CMD======
cd BigDirectorGo/
lsof -i:12309
lsof -i:12309 | awk 'NR>1 {print $2}'|xargs kill -9
nohup ./main > nohup.out 2>&1 &
echo "reload success"
lsof -i:12309
======END======
out: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
out: main 24105 root 11u IPv6 32920645 0t0 TCP *:12309 (LISTEN)
out: reload success
2021/03/17 18:32:58 Process exited with status 1
Why does this "lsof -i:12309" command exit with status 1?
@appleboy I am getting the same strange error during the execution of a simple command.
The pipeline step that fails:
- name: Rollback on "Release Deploy" step error
id: rollback_release_deploy
if: steps.release_prepare.outcome == 'success' && steps.release_deploy.outcome != 'success'
uses: appleboy/ssh-action@master
env:
ROOT: ${{ secrets.DEV_REMOTE_TARGET }}
RELEASE: ${{ secrets.DEV_REMOTE_TARGET }}/releases/${{ env.release_name }}
with:
host: ${{ secrets.DEV_REMOTE_HOST }}
username: ${{ secrets.DEV_REMOTE_USER }}
key: ${{ secrets.DEV_REMOTE_SSH_KEY }}
envs: ROOT
script_stop: true
script: |
#### swap back to the previous release
cd $ROOT
[ -e previous ] && rm current && mv previous current
debug: false
As you can see, apart from passing the $ROOT folder path, there is nothing special.
So in a few words: we cd into that $ROOT folder and check if the previous symlink exists - then remove it and move the previous symlink into current (basically, reverting the recently failed release to point to an old release folder).
However, the output for a such single-line script is:
======CMD======
#### swap back to the previous release
cd $ROOT
[ -e previous ] && rm current && mv previous current
======END======
err:
out:
out:
out:
2022/10/27 19:03:01 Process exited with status 1
However, if you delete directive script_stop: true
It will output success:
======CMD======
#### swap back to the previous release
cd $ROOT && [ -e previous ] && rm current && mv previous current
======END======
==============================================
✅ Successfully executed commands to all host.
==============================================
P.S. As @00LT00 said, there is nothing more to investigate as even "debug: true" does nothing at the output is exactly the same.
P.P.S. Also, I was getting the same error when tried to pass a pretty complicated bash script with IF...THEN logic. It was executing well in the shell, but once I paste that script into the pipeline, it fails with a "status code 1" error as per the above.