mirror of https://github.com/krallin/tini.git
See: https://github.com/krallin/tini/pull/114#issuecomment-382756277pull/114/head
parent
eb0f6de3a5
commit
1487373aa2
3 changed files with 72 additions and 1 deletions
@ -0,0 +1,30 @@ |
||||
#!/usr/bin/env python |
||||
from __future__ import print_function |
||||
|
||||
import os |
||||
import sys |
||||
import subprocess |
||||
|
||||
|
||||
def main(): |
||||
pid = os.getpid() |
||||
|
||||
tini = sys.argv[1] |
||||
ret = sys.argv[2] |
||||
stage_2 = os.path.join(os.path.dirname(__file__), "stage_2.py") |
||||
|
||||
cmd = [ |
||||
tini, |
||||
"-vvv", |
||||
"-p", |
||||
"SIGUSR1", |
||||
"--", |
||||
stage_2, |
||||
str(pid), |
||||
ret |
||||
] |
||||
|
||||
subprocess.Popen(cmd).wait() |
||||
|
||||
if __name__ == "__main__": |
||||
main() |
@ -0,0 +1,25 @@ |
||||
#!/usr/bin/env python |
||||
from __future__ import print_function |
||||
|
||||
import os |
||||
import sys |
||||
import signal |
||||
import time |
||||
|
||||
|
||||
def main(): |
||||
ret = sys.argv[2] |
||||
|
||||
def handler(*args): |
||||
with open(ret, "w") as f: |
||||
f.write("ok") |
||||
sys.exit(0) |
||||
|
||||
signal.signal(signal.SIGUSR1, handler) |
||||
pid = int(sys.argv[1]) |
||||
|
||||
os.kill(pid, signal.SIGKILL) |
||||
time.sleep(5) |
||||
|
||||
if __name__ == "__main__": |
||||
main() |
Loading…
Reference in new issue