nodejs热加载工具:node-supervisor

nodejs的一个supervisor脚本。它运行您的程序,并监视代码更改,因此您可以使用热代码重新加载行为,而不必担心内存泄漏并确保清理所有模块间引用,并且没有全新的require系统;

安装:

npm install supervisor -g

节点管理器用于在程序崩溃时重新启动程序。 当* .js文件发生更改时,它还可用于重新启动程序。

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

Required:
  <program>
    The program to run.

Options:
  -w|--watch <watchItems>
       用于查看更改的逗号分隔的文件夹或js文件列表。     
       当发生对js文件的更改时,重新加载该程序,默认为'.'

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

  --ignore-symlinks
    Ignore symlinks :)
    
  -s|--timestamp
    Log timestamp after each run.
    Make it easy to tell when the task last ran.
    
  -p|--poll-interval <milliseconds>
    How often to poll watched files for changes.
    Defaults to Node default.

  -e|--extensions <extensions>
    A comma-delimited list of file extensions to watch for changes.
    Default is 'node,js' (or when CoffeeScript, 'node,js,coffee,litcoffee').

  -x|--exec <executable>
    The executable that runs the specified program.
    Default is 'node'

  -pid|--save-pid <path>
    Save supervisor's process id to a file at the given path.

  --debug[=port]
    Start node with --debug flag.

  --debug-brk[=port]
    Start node with --debug-brk flag.

  --harmony
    Start node with --harmony flag.

  --inspect
    Start node with --inspect flag.

  -n|--no-restart-on error|exit|success
    Don't automatically restart the supervised program if it ends.
    Supervisor will wait for a change in the source files.
    If "error", an exit code of 0 will still restart.
    If "exit", no restart regardless of exit code.
    If "success", no restart only if exit code is 0.

-t|--non-interactive
    Dissable interactive capacity
    With this option, supervisor won't listen to stdin

  --force-watch
    Use fs.watch instead of fs.watchFile.
    This may be useful if you see a high cpu load on a windows machine.

  -k|--instant-kill
    Instantly kills the server process, instead of gracefully shutting down the server.
	This can be useful when the node app has events attached to SIGTERM or SIGINT so as to do a graceful shutdown before the process exits.
	
 -RV|--restart-verbose
    Logs the file(s) that caused supervisor to restart

  -h|--help|-?
    Display these usage instructions.

  -q|--quiet
    Suppress DEBUG messages


Options available after start:
  rs - restart process. Useful when you want to restart your program even
       if no file has changed.

比如:

  supervisor myapp.js
  supervisor myapp.coffee
  supervisor -w scripts -e myext -x myrunner myapp
  supervisor -w lib,server.js,config.js server.js
  supervisor -- server.js -h host -p port

 

运行:

supervisor bin/www

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值