【发布时间】:2020-05-09 16:47:41
【问题描述】:
我在从 Python 启动节点服务器时遇到问题。我试着这样称呼它:
os.system("nohup node /opt/solvoerp/solvo-erp/w_sender/app.js")
但我收到以下错误
(node:83046) UnhandledPromiseRejectionWarning: Error: Page crashed!
(node:83046) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:83046) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
如果我从 shell 执行命令,节点服务器会正确执行,可能是 shell 问题。
【问题讨论】:
-
节点应用程序是否运行?您附加了一些警告,但从文本中,它寻求节点应用程序 not 因错误而终止。还有一个问题——这个代码是更大的 Python 程序/应用程序的一部分吗?当你打开一个 python shell,import os,然后运行这个语句会发生什么?
-
另外,请注意,从 shell 运行的环境可能与 Python 代码维护的环境不同。最后,使用
os.system通常是调用外部进程的错误方式。标准库的subprocess模块有许多您可以(并且应该)用于此目的的函数和对象。 -
@Roy2012 是的,它是一个更大的 python 程序的一部分,它从环境中看到了错误。
-
@AmitaIrron 与子进程有相同的错误。谢谢,我会尝试调试环境导致错误的原因
标签: python node.js shell nohup