我需要编写一个bash脚本来启动一个阻止进程,然后从中分离出来,以便我可以运行一些其他命令来配置该正在运行的进程,然后重新附加到原始进程中,以便ctrl + c可以杀死它。
具体来说,这恰好是Google Cloud PubSub模拟器,因此bash脚本看起来类似于以下伪代码:
# TODO: pubsub will block, but I need to detach from it so I can create topics.
gcloud beta emulators pubsub start --host-port=localhost:8086
python publisher.py myapp create topic1
python publisher.py myapp create topic2
# TODO: Now I need to reattach to the pubsub process.
答案 0 :(得分:1)
由于上面@Barmar的评论,我在MacOS上有一个可行的解决方案:
screen -S pub_sub_emulator -dm gcloud beta emulators pubsub start --host-port=localhost:8086
python publisher.py myapp create topic1
python publisher.py myapp create topic2
screen -r pub_sub_emulator