G
G
GavriKos2020-03-28 15:44:05
Python
GavriKos, 2020-03-28 15:44:05

How to restart python deomn from itself?

Hello.
There is a daemon (service? How is this thing properly called) in python. Runs through systemd. According to some internal trigger directly in the script, you need to turn off the daemon, execute a number of commands, and start the daemon.

To simplify the subject area, this is a telegram bot with a self-update from the git at the user's command.

I tried the following implementations:
1) From the bot script through subprocess.Popen (there were different options, not only Popen), another script is launched, which, in theory, should not depend on the current one, and should perform all the necessary operations. The result - the main demon stops, but nothing happens further. Alas, the logs were not filmed then.
2) Another daemon starts (restarts) from the bot script, which is already trying to execute the necessary commands. It starts, that's for sure. But the logs are empty.

Actually a question - as such task basically it is more correct to solve?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-03-28
@GavriKos

For me, it's not worth it to be so perverted. It is better to write a separate script that will deploy this bot: download new code, configure something, restart the systemd unit of this bot.
ZY this separate script not to start through subprocess.Popen, etc., and to make a separate demon.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question