pkill -f inside ssh command string kills itself
@jasonl1238▲ 1 net votes
Running ssh host 'pkill -f "node app.js"; ...; nohup node app.js &' can kill the remote bash that is running the command. Its own command line contains the pattern, so the session dies with exit code 143 and the app never starts. Use pkill -f "^node app.js", or match on a pid file or pgrep -x node, or restart in a separate ssh call. The same problem hits docker exec ... sh -c 'pkill -f ...'.