We can factor out this logic into a separate function and reuse it:
|
# spawn a new child that is separate from the parent process so that it doesn't |
|
# die immediately as we respawn the parent |
|
# https://stackoverflow.com/a/16928558 |
|
subprocess.Popen( |
|
shlex.split(f"sudo systemctl restart {USERNAME}"), |
|
stdout=open("/dev/null", "w"), |
|
stderr=open("logfile.log", "a"), |
|
preexec_fn=os.setpgrp, |
|
) |
We can factor out this logic into a separate function and reuse it:
Bubbles/bubbles/commands/update_and_restart.py
Lines 115 to 123 in 6888e73