如何使用PM2观看和重新加载ExpressJS应用 [英] How to watch and reload an ExpressJS app with pm2

查看:66
本文介绍了如何使用PM2观看和重新加载ExpressJS应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发ExpressJS应用程序.我使用pm2加载它:

I'm developing an ExpressJS app. I use pm2 to load it:

myapp$ pm2 start bin/www

这很好,除了添加-watch 标志似乎不起作用外,其他方法都没有.每次更改JS源时,都需要显式重新启动它,以使更改生效:

This works fine, except that adding the --watch flag doesn't seem to work; every time I change the JS source I need to explicitly restart it for my changes to take effect:

myapp$ pm2 restart www

我做错了什么?我已经用非ExpressJS应用程序尝试过-watch 标志,它按预期工作.

What am I doing wrong? I've tried the --watch flag with a non-ExpressJS app and it worked as expected.

推荐答案

请参阅此解决方案在堆栈溢出中

问题与pm2正在监视的路径有关,是否与执行文件或项目的实际根目录有关.

The problem is relative to the path where pm2 is watching, and if it is relative to the execution file or the actual root path of the project.

这篇关于如何使用PM2观看和重新加载ExpressJS应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆