How to run shell script to restart server by application

Asked

Viewed 196 times

1

I need to run a shell from Rails with a small difference, I need the script to continue running even if the server(puma) process is killed.

I added an update system inside my application, but I need to restart the server to run the changes. When I run the sh file to restart the server, it shuts down the server and stops running the script and consequently does not start the server again.

  • Welcome colleague. It is not necessary to post your question in English. I translated the title, if it is incorrect please change.

  • Junior is very strange to have to restart the application to update something, since the language is interpreted, we should be able to search for this new information in files or something. What is the problem you are actually having that you are trying to solve with Restart server ?

1 answer

1


In order for you to run a script disconnected from the process that started it, you need to send it to the background. For example if you are running:

sh . /meuscript.sh

just add & in the execution it will run regardless of the process that created it, staying that way:

sh . /meuscript.sh &

Thus the process that created it, can be terminated, without it being also.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.