使用 ProcessBuilder 开发解决方案以在 Windows 和 Linux 上启动 perl 脚本。该脚本由 REST API 启动。 Perl 脚本在 Web 服务器 (Liberty Websphere) 上执行停止/启动操作。 REST API 等待此类脚本的结果。但由于服务器正在关闭,其余 api 会断开连接,perl 脚本也会停止。 我正在尝试找到启动不依赖于 Web 服务器进程的 perl 脚本的方法。 主要目标是通过加载补丁文件来更新 Web 应用程序上的一些资源,然后在此补丁文件上执行 perl 脚本。
最佳答案
将进程与父进程分离(孤立)。
http://enwp.org/Orphan_process
A low-level approach is to fork twice, running the desired process in the grandchild, and immediately terminating the child. The grandchild process is now orphaned, and is not adopted by its grandparent, but rather by init.
请参阅Proc-Daemon source code了解详情。
关于java - 如何在 Websphere Liberty 上启动新流程并使其可靠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59184641/