我正在使用supervisor自动重新加载我的node.js,例如
supervisor -w . app.js
Run Code Online (Sandbox Code Playgroud)
但是我无法弄清楚如何让supervisor在debug中运行node.js进程,例如相当于
node --debug app.coffee
Run Code Online (Sandbox Code Playgroud)
有人有任何想法吗?
我正在使用WebStorm作为我的节点IDE并且非常喜欢它,但是当我通过WebStorm运行节点时,我无法弄清楚如何使用节点管理器.有没有人得到这个工作?我想我只是不确定如何通过supervisor
参数,以便它在启动节点文件时使用它.
我有一个节点应用程序有一个/ public子目录,其中只有静态文件(js,css,html等)以及需要编译的scss文件
我打字运行我的应用程序
sudo supervisor -n error -e js,json,scss,jade -p 1000 app
Run Code Online (Sandbox Code Playgroud)
因此,只要具有这些扩展名的文件在我的根项目目录中发生更改,服务器就会重新启动.
问题是public下的js文件不应该导致重启.有没有办法忽略特定目录中的文件时间?或者如果没有,有没有办法忽略一个目录(当我使用scss时我会切换主管调用).
可以使用这样的调试参数运行节点
$ node --debug src/file.js
Run Code Online (Sandbox Code Playgroud)
我也可以通过这样的咖啡脚本二进制传递该参数
$ coffee --nodejs --debug src/file.coffee
Run Code Online (Sandbox Code Playgroud)
哪个有效.但是当我让主管参与时,事情变得更加困难.运行咖啡脚本没问题:
$ supervisor -w src src/file.coffee
Run Code Online (Sandbox Code Playgroud)
但是我想调试我和主管一起运行的咖啡脚本.我如何--debug
通过主管发送论据?我尝试将可执行文件设置为带有如下参数的字符串:
$ supervisor -w src -x "coffee --nodejs --debug" src/server.coffee
Run Code Online (Sandbox Code Playgroud)
这产生了无限重复的错误信息
DEBUG: Starting child process with 'coffee --nodejs --debug src/server.coffee' DEBUG: execvp(): No such file or directory
这很奇怪,因为coffee --nodejs --debug src/server.coffee
在终端中运行起作用.
那么如何通过主管发送论据呢?
编辑:我想扩展我的问题,提到我现在也尝试使用 nodemon.似乎 nodemon被认为比 node-supervisor更受欢迎,所以我会接受任何解释--debug
当通过 nodemon启动coffee脚本时如何传递给节点进程的答案
编辑:这是 nodemon的输出.显然,参数不会以相同的顺序传递:-( …
Supervisor是Node.js的一个程序包,它监视应用程序目录中的文件以进行修改,并在发生修改时重新加载应用程序.
此脚本将符号链接解释为常规文件并注销警告.我想分叉Supervisor,以便完全修复或者产生更具描述性的警告.
如何使用Node.js的文件系统模块来确定给定文件是否真的是符号链接?
当我安装快速脚手架应用程序
express
Run Code Online (Sandbox Code Playgroud)
然后运行npm install
npm install
Run Code Online (Sandbox Code Playgroud)
然后运行主管
supervisor app
Run Code Online (Sandbox Code Playgroud)
我明白了
Starting child process with 'node app'
Program node app exited with code 0
Run Code Online (Sandbox Code Playgroud)
app.js文件是一个基本的默认快速实例.
var express = require('express');
var path = require('path');
var favicon = require('static-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
var users = require('./routes/users');
var app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(favicon());
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
app.use('/users', …
Run Code Online (Sandbox Code Playgroud) 我只是尝试使用终端安装nodemon或supervisor,我不断收到这个我不明白的错误.我尝试以管理员身份运行sudo npm install supervisor -g
似乎有效,但是当我删除/添加一些js代码时没有.有任何想法吗?
Squirrels-MacBook-Air:lesson7_examples Squirrel$ npm install nodemon -g
npm http GET https://registry.npmjs.org/nodemon
npm http 304 https://registry.npmjs.org/nodemon
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/nodemon'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/nodemon']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/nodemon',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/nodemon',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR! 'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try …
Run Code Online (Sandbox Code Playgroud) 我正在使用Docker和fig来构建NodeJS dev-env.
当我使用nodemon来监视server.js时,更改server.js将不会重新启动服务器.
CMD ["nodemon", "/nodeapp/server.js"]
Run Code Online (Sandbox Code Playgroud)
但是当我从nodemon变为主管时,它就起作用了!
CMD ["supervisor", "/nodeapp/server.js"]
Run Code Online (Sandbox Code Playgroud)
有谁知道问题在哪里?
更多信息如下:
我的图文件夹结构:
app/server.js
package.json
node_modules/
fig.yml
Dockerfile
Run Code Online (Sandbox Code Playgroud)
fig.yml:
nodejs:
build: .
ports:
- "8080:8080"
Run Code Online (Sandbox Code Playgroud)
Dockerfile:
RUN apt-get update --fix-missing
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# NVM
RUN curl -sL https://deb.nodesource.com/setup | sudo bash - && \
apt-get install -y nodejs
VOLUME ./app:/nodeapp
WORKDIR /nodeapp
RUN rm /bin/sh && ln -s /bin/bash /bin/sh && \
npm install -g nodemon mocha supervisor
CMD ["nodemon", "/nodeapp/server.js"]
Run Code Online (Sandbox Code Playgroud)
Server.js :(来自NodeJS网站的示例代码)
var …
Run Code Online (Sandbox Code Playgroud) 在运行Ubuntu 11.10的开发虚拟机上安装和设置node.js之后,我希望主管在启动时自动启动,在需要时调用并重新加载node.js.
在我的默认用户在终端中运行时,下面的代码片段运行良好,但是如何让它在启动时运行?
cd /var/ && supervisor -w www www/myapp/app.js
Run Code Online (Sandbox Code Playgroud)
谢谢
我刚刚开始进入node.js,通过一些教程.我只是尝试节点主管,但在运行时遇到一些麻烦.我正在使用express来设置应用程序,然后安装supervisor包.
使用以下命令启动App:
npm start
Run Code Online (Sandbox Code Playgroud)
正如我所期望的那样,一切都像以前做过几次一样有效.
但是,如果我启动supervisor(node_module\.bin\supervisor app.js
),我会收到以下消息:
Starting child process with 'node app.js'
Program node app.js exited with code 0
Run Code Online (Sandbox Code Playgroud)
我到处寻找答案,但我很难过.我可能做了一些蠢事,有人可以帮忙吗?
提前致谢
这是我当前的package.json文件:
{
"name": "application-name",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./bin/www",
},
"dependencies": {
"express": "~4.0.0",
"static-favicon": "~1.0.0",
"morgan": "~1.0.0",
"cookie-parser": "~1.0.1",
"body-parser": "~1.0.0",
"debug": "~0.7.4",
"jade": "~1.3.0",
"less-middleware": "0.1.15",
"supervisor": "*"
}
}
Run Code Online (Sandbox Code Playgroud) node-supervisor ×10
node.js ×10
nodemon ×3
coffeescript ×1
debugging ×1
docker ×1
express ×1
fig ×1
fs ×1
javascript ×1
linux ×1
npm ×1
terminal ×1
ubuntu ×1
webstorm ×1