【发布时间】:2017-03-21 10:38:34
【问题描述】:
我正在使用 PhpStorm 制作图像(作为我构建可移植开发环境的一部分)。除了 PhpStorm 无法自行重启之外,一切都运行得非常顺利。它使用bin/restart.py 脚本来达到这个目的,这在 dockerized 时不起作用。
这是脚本的主体:
#!/usr/bin/env python
# Waits for the parent process to terminate, then executes specified commands.
import os
import signal
import sys
import time
if len(sys.argv) < 3:
raise Exception('usage: restart.py <pid> <path> [optional command]')
signal.signal(signal.SIGHUP, signal.SIG_IGN)
pid = int(sys.argv[1])
while os.getppid() == pid:
time.sleep(0.5) // ***
if len(sys.argv) > 3:
to_launch = sys.argv[3:]
os.spawnv(os.P_WAIT, to_launch[0], to_launch)
to_launch = ['/usr/bin/open', sys.argv[2]] if sys.platform == 'darwin' else [sys.argv[2]]
os.execv(to_launch[0], to_launch)
脚本运行到标有*** 的行——即在父进程退出后立即运行。
我尝试使用 bash 根进程以及 dumb-init 或 TINI 进程运行 PhpStorm,没有任何区别。
任何想法出了什么问题以及如何“解决”这个问题?是否有一些特定的信号必须在根进程中实现,或者它是 docker 的特性,不允许这种用途?
【问题讨论】: