pm2进程使用旧系统环境变量就复活了
我创建了一个用于订阅OPC-UA服务器并将数据存储在我们的S3存储桶上的节点应用程序。我正在使用 node-opcua 用于此目的的模块。
我正在通过RDP在Windows Server上工作,node-opcua
模块在%localappdata%\ temp
作为过程的一部分下创建了一些文件,并使用它。我正在使用pm2
来运行该应用程序,并且它通过tmp
和temp
环境变量获取这些文件的路径,这些变量是由该文件动态生成的处理本身。
当Windows Server重新启动时,它将删除这些文件和新文件的位置更新。我已经运行pm2保存
,并将pm2复活
命令放在批处理文件中,该命令在Windows启动中具有快捷键,以确保该过程自动启动。
问题是PM2进程是复活的,但仍将错误%localappData%\ temp \ {some_path}文件未找到
是由node> node> node-opcua
流程运行的。 pm2 。我运行pm2重新启动
手动但仍未奏效。
I have created a node application that is for subscribing to an OPC-UA server and storing the data on our s3 bucket. I am using the node-opcua module for that purpose.
I am working on a Windows server via RDP and the node-opcua
module creates some files under %LOCALAPPDATA%\Temp
as part of the process and uses it. I am using pm2
to run the application and it is getting the path of those files via TMP
and TEMP
environment variables which are dynamically generated by the process itself.
When the Windows server restarts it delete those files and the location updates of the new file. I already have run pm2 save
and put the pm2 resurrect
command in the Batch file which has a shortcut in the windows startup to make sure the process automatically gets started.
The issue was that the pm2 process was resurrected but still throwing the error %LOCALAPPDATA%\Temp\{some_path} file not found
by the node-opcua
process which was running through pm2. I ran pm2 restart
manually but still didn't work out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我从 node-opcua 模块的问题出发,思考如何让它使用新的系统变量,但这并不在 had 中,因为该过程不断创建和删除临时文件,所以我需要 pm2 来使用新的系统变量,该变量在系统重新启动后具有更新的路径,并且即使在
pm2重新启动
后也没有更新。因此,为了更新变量,我想出了两种解决方案:
pm2 restart {name} --update-env
在pm2 复活
后,系统变量将被更新。First I was thinking of it from the problem with the node-opcua module and thought about how can make it use the new system variables, but that was not in had as the process keeps making and deleting temporary files, so I need the pm2 to use the new system variable which has the updated path after system reboot and was not updating even after
pm2 restart
.So, for updating the variables I figured out two solutions:
pm2 restart {name} --update-env
afterpm2 resurrect
and the system variables will be updated.