【问题标题】:How to restart a process inside a container / Restarting PhpStorm using original restart.py如何重新启动容器内的进程/使用原始 restart.py 重新启动 PhpStorm
【发布时间】: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-initTINI 进程运行 PhpStorm,没有任何区别。

任何想法出了什么问题以及如何“解决”这个问题?是否有一些特定的信号必须在根进程中实现,或者它是 docker 的特性,不允许这种用途?

【问题讨论】:

    标签: python docker phpstorm


    【解决方案1】:

    解决您的问题的最简单方法是重新启动容器,这就是首先将进程放入容器中。

    【讨论】:

    • 这不是解决方案,因为 PhpStorm 重启不起作用。
    最近更新 更多