nodejs中supervisor怎样设置其忽略关注的文件?
发布于 8 年前 作者 helloMane 5606 次浏览 来自 问答

想让supervisor忽略某些需要经常改动的文件,避免服务器经常重新刷新。应该怎么弄?

7 回复
klesh@knb:~/Projects/hhApp$ supervisor -h

Node Supervisor is used to restart programs when they crash.
It can also be used to restart programs when a *.js file changes.

Usage:
  supervisor [options] <program>
  supervisor [options] -- <program> [args ...]

Required:
  <program>
    The program to run.

Options:
  -w|--watch <watchItems>
    A comma-delimited list of folders or js files to watch for changes.
    When a change to a js file occurs, reload the program
    Default is '.'

  -i|--ignore <ignoreItems>
    A comma-delimited list of folders to ignore for changes.
    No default
以下省略

@klesh 我就是有点看不懂-i|–ignore <ignoreItems>不知道该怎么写这个。。。。 我写的是-i index.html但是感觉好像没有效果。(index.html路径为app/index.html) 请问一下我这么写是不是错的?

app 是包的根目录还是子目录?如果是子目录应该是 -i app/index.html 或者 直接忽略 -i app 直接忽略整个目录。

@klesh 文件目录是app/ires以及另一个文件app/res.zip我命令写的是: supervisor – app.js -i app/ires,app/res.zip 但是还是会出现重定向的问题。甚至我把整个app文件夹都忽略了还是会出现重定向问题。。。。 我都要炸了。。。

那你试下正向监测,用-w 只有指定的文件夹变动时才刷新。新版的 expressjs 应该是要执行 ./bin/www 才是的

supervisor -w routes,views,models ./bin/www

@klesh 我知道了,之前官网看的例子不能那么写,参照你给我的写法,我这么写就对了 1.jpg 2.jpg

supervisor -i public,node_modules bin/www

回到顶部