Using SSH (scripts, plugins, etc.) to start processes

I am trying to complete a remote deployment by restarting two processes that make my Python application work. Thus

process-one & process-two & 

I tried to execute Execute Shell Script by doing this

 ssh -i ~/.ssh/id_... user@xxx.xxx ./startup.sh 

I tried using the Jekins SSH Plugin and Publish over the SSH plugin and do the same. All the previous steps, stopping processes, restarting other services, outputting new code works fine. But when I get to the part where I start services. It executes these two lines, and none of the plugins or the default Script can exit the server. They all either hang until I restart Jekins, or exit it in the case of the Publish Over SSH plugin. Therefore, my assembly either requires a restart of Jenkins, or is marked by instability.

Has anyone had success doing something like this? I tried

 nohup process-one & 

But the same thing happened. It's not that services are getting confused either, because they really start off normally, but simply that Jenkins doesn't seem to understand this.

Any help would be greatly appreciated. Thanks.

+4
source share
1 answer

What probably happens when a process, when it is spawned (even with &), consumes the same input and output as your ssh connection. Jenkins waits until these pipes are empty before work closes, and waits for processes to complete. You can make sure that by killing your processes, you will see that jenkins is shutting down.

Dissociation of outputs and remote start of the process

There are several solutions to your problem:

Python Demons

The initial question was focused on SSH, so I did not fully describe how to start the python process as a daemon. This is mainly described in other methods:

+5
source

Source: https://habr.com/ru/post/1497043/


All Articles