pm2进程使用旧系统环境变量就复活了

发布于 2025-01-17 18:08:23 字数 793 浏览 6 评论 0原文

我创建了一个用于订阅OPC-UA服务器并将数据存储在我们的S3存储桶上的节点应用程序。我正在使用 node-opcua 用于此目的的模块。

我正在通过RDP在Windows Server上工作,node-opcua模块在%localappdata%\ temp作为过程的一部分下创建了一些文件,并使用它。我正在使用pm2来运行该应用程序,并且它通过tmptemp环境变量获取这些文件的路径,这些变量是由该文件动态生成的处理本身。

当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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆流 2025-01-24 18:08:23

首先,我从 node-opcua 模块的问题出发,思考如何让它使用新的系统变量,但这并不在 had 中,因为该过程不断创建和删除临时文件,所以我需要 pm2 来使用新的系统变量,该变量在系统重新启动后具有更新的路径,并且即使在pm2重新启动后也没有更新。

因此,为了更新变量,我想出了两种解决方案:

  • 删除旧进程并启动一个新的 pm2 进程来运行该应用程序,并将其放入服务器重新启动时调用的批处理文件中
  • 添加 pm2 restart {name} --update-envpm2 复活 后,系统变量将被更新。

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:

  • Either delete the old process and initiate a new pm2 process to run that application and put it in the batch file which is being called at server reboot
  • Adds pm2 restart {name} --update-env after pm2 resurrect and the system variables will be updated.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文