如何使用DEBUG选项启动pm2进程

时间:2022-02-23 07:02:14

I have an express app that I start in terminal with following command to enable debug logs in it:

我有一个express应用程序,我在终端以以下命令开始,在其中启用调试日志:

DEBUG=custom:* npm start (on Ubuntu)
SET DEBUG=custom:* & npm start (on Windows)

On production server, I start app with PM2 using following command:

在产品服务器上,我使用PM2启动app,使用以下命令:

pm2 start bin/www -i 0

But this does not enable the debug logs in my code, so the debug statements are not added to the logs, only console.error() are added to the log files. How can I pass the DEBUG=custom:* option while starting my app with PM2?

但是这并不能在我的代码中启用调试日志,所以调试语句没有添加到日志中,只有console.error()被添加到日志文件中。如何在使用PM2启动应用程序时传递DEBUG=custom:*选项?

1 个解决方案

#1


2  

Try DEBUG='custom:*' pm2 start bin/www -i 0

尝试调试='custom:*' pm2启动bin/www -i - 0。

If you are restarting an existing process add the --update-env flag:

如果您正在重新启动一个现有进程,请添加—update-env标志:

DEBUG='custom:*' pm2 restart bin/www -i 0 --update-env

DEBUG='custom:*' pm2重新启动bin/www -i - 0, updateenv。

#1


2  

Try DEBUG='custom:*' pm2 start bin/www -i 0

尝试调试='custom:*' pm2启动bin/www -i - 0。

If you are restarting an existing process add the --update-env flag:

如果您正在重新启动一个现有进程,请添加—update-env标志:

DEBUG='custom:*' pm2 restart bin/www -i 0 --update-env

DEBUG='custom:*' pm2重新启动bin/www -i - 0, updateenv。