当我在没有调试或仅使用 --debug 的情况下启动 sails 并包含 --verbose 作为应用程序参数时,它会向我显示 grunt 运行的详细信息(请参阅下面的第一个日志示例)。
但是,当我使用 debug-brk= 运行应用程序时,它不会运行 grunt。 (请参阅下面的第二个日志示例)。我在另一个论坛上发布了此内容,有人建议“很可能 grunt 是使用与父应用程序相同的调试端口作为子进程生成的......而且,由于端口已经绑定(bind),因此它被挂起”。证据似乎支持这一点,但我无法找到 grunt 模块通过 sails 模块中的端口的位置。
有人遇到过这种情况吗?我认为这是一件很常见的事情,而且我遗漏了一些明显的东西。
问候
我正在使用... sails 0.10.5 Node 0.10.29 咕噜0.4.5 grunt-cli 0.1.13
这是一个良好运行的示例..没有调试或仅使用 --debug (不是 --debug-brk)
C:\Users\myuser\git\datavis>node app.js --verbose
verbose: Setting Node environment...
verbose: Please run `npm install coffee-script` to use coffescript (skipping for now)
verbose: moduleloader hook loaded successfully.
verbose: Loading app config...
verbose: userconfig hook loaded successfully.
verbose: Exposing global variables... (you can disable this by modifying the properties in `sails.config.globa
verbose: logger hook loaded successfully.
verbose: request hook loaded successfully.
verbose: Loading the app's models and adapters...
verbose: Loading app models...
verbose: Loading app adapters...
verbose: Loading blueprint middleware...
verbose: blueprints hook loaded successfully.
verbose: Loading runtime custom response definitions...
verbose: responses hook loaded successfully.
verbose: controllers hook loaded successfully.
verbose: Loading policy modules from app...
verbose: Finished loading policy middleware logic.
verbose: policies hook loaded successfully.
verbose: Loading app services...
verbose: services hook loaded successfully.
verbose: csrf hook loaded successfully.
verbose: cors hook loaded successfully.
i18n:debug will write to C:\Users\myuser\git\datavis\config\locales\en.json +0ms
i18n:debug read C:\Users\myuser\git\datavis\config\locales\en.json for locale: en +1ms
i18n:debug will write to C:\Users\myuser\git\datavis\config\locales\es.json +1ms
i18n:debug read C:\Users\myuser\git\datavis\config\locales\es.json for locale: es +0ms
i18n:debug will write to C:\Users\myuser\git\datavis\config\locales\fr.json +0ms
i18n:debug read C:\Users\myuser\git\datavis\config\locales\fr.json for locale: fr +1ms
i18n:debug will write to C:\Users\myuser\git\datavis\config\locales\de.json +0ms
i18n:debug read C:\Users\myuser\git\datavis\config\locales\de.json for locale: de +0ms
verbose: i18n hook loaded successfully.
verbose: session hook loaded successfully.
verbose: Loading app Gruntfile...
verbose: Tracking new grunt child process...
verbose: grunt hook loaded successfully.
verbose: http hook loaded successfully.
verbose: Overriding ejs engine config with ejslocals to implement layout support...
verbose: Configuring socket (ws://) server...
verbose: sockets hook loaded successfully.
verbose: Loading user hooks...
verbose: Located 0 user hook(s)...
verbose: views hook loaded successfully.
verbose: Setting default Express view engine to ejs...
verbose: Initialized 0 user hook(s)...
verbose: userhooks hook loaded successfully.
verbose: Loading adapter ( sails-disk ) for sdm from `node_modules` directory...
verbose: Starting ORM...
verbose: orm hook loaded successfully.
verbose: pubsub hook loaded successfully.
verbose: Built-in hooks are ready.
verbose: Instantiating registry...
verbose: Loading router...
verbose: Policy-controller bindings complete!
verbose: Waiting for all hooks to declare that they're ready...
verbose: All hooks were loaded successfully.
verbose: Starting app at C:\Users\myuser\git\datavis...
verbose: Running the setup logic in `sails.config.bootstrap(cb)`...
verbose: Restricting access to explicit host: 0.0.0.0
info:
info:
info: Sails <|
info: v0.10.5 |\
info: /|.\
info: / || \
info: ,' |' \
info: .-'.-==|/_--'
info: `--'-------'
info: __---___--___---___--___---___--___
info: ____---___--___---___--___---___--___-__
info:
info: Server lifted in `C:\Users\myuser\git\datavis`
info: To see your app, visit http://0.0.0.0:8181
info: To shut down Sails, press <CTRL> + C at any time.
debug: --------------------------------------------------------
debug: :: Tue Oct 14 2014 09:04:11 GMT-0400 (Eastern Daylight Time)
debug: Environment : development
debug: Host : 0.0.0.0
debug: Port : 8181
debug: --------------------------------------------------------
verbose: Grunt :: Running "clean:dev" (clean) task
verbose: Grunt :: >> 191 paths cleaned.
verbose: Grunt :: Running "jst:dev" (jst) task
>> Destination not written because compiled files were empty.
Running "less:dev" (less) task
verbose: Grunt :: Running "copy:dev" (copy) task
verbose: Grunt :: Copied 178 files
Running "coffee:dev" (coffee) task
>> 0 files created.
Running "sails-linker:devJs" (sails-linker) task
padding length 4
File "views/layout.ejs" updated.
Running "sails-linker:devStyles" (sails-linker) task
padding length 4
File "views/layout.ejs" updated.
Running "sails-linker:devTpl" (sails-linker) task
padding length 4
File "views/layout.ejs" updated.
Running "sails-linker:devJsJade" (sails-linker) task
Running "sails-linker:devStylesJade" (sails-linker) task
Running "sails-linker:devTplJade" (sails-linker) task
verbose: Grunt :: Running "watch" task
Waiting...
verbose: Lowering sails...
verbose: Sent kill signal to child process (21060)...
verbose: Shutting down socket server...
verbose: Socket server shut down successfully.
verbose: Shutting down HTTP server...
这是带有 --debug-brk= 的示例
C:\Program Files\nodejs\node.exe --debug-brk=53447 --nolazy app.js --verbose
debugger listening on port 53447
verbose: Setting Node environment...
verbose: Please run `npm install coffee-script` to use coffescript (skipping for now)
verbose: moduleloader hook loaded successfully.
verbose: Loading app config...
verbose: userconfig hook loaded successfully.
verbose: Exposing global variables... (you can disable this by modifying the properties in `sails.config.globals`)
verbose: logger hook loaded successfully.
verbose: request hook loaded successfully.
verbose: Loading the app's models and adapters...
verbose: Loading app models...
verbose: Loading app adapters...
verbose: Loading blueprint middleware...
verbose: blueprints hook loaded successfully.
verbose: Loading runtime custom response definitions...
verbose: responses hook loaded successfully.
verbose: controllers hook loaded successfully.
verbose: Loading policy modules from app...
verbose: Finished loading policy middleware logic.
verbose: policies hook loaded successfully.
verbose: Loading app services...
verbose: services hook loaded successfully.
verbose: csrf hook loaded successfully.
verbose: cors hook loaded successfully.
Mon, 13 Oct 2014 01:31:42 GMT i18n:debug will write to c:\Users\cdeanhar\git\datavis\config\locales\en.json
debug: --------------------------------------------------------
Mon, 13 Oct 2014 01:31:42 GMT i18n:debug read c:\Users\cdeanhar\git\datavis\config\locales\en.json for locale: en
debug: :: Sun Oct 12 2014 21:31:44 GMT-0400 (Eastern Daylight Time)
debug: Environment : development
debug: Host : 0.0.0.0
debug: Port : 8181
debug: --------------------------------------------------------
Mon, 13 Oct 2014 01:31:42 GMT i18n:debug will write to c:\Users\cdeanhar\git\datavis\config\locales\es.json
Mon, 13 Oct 2014 01:31:42 GMT i18n:debug read c:\Users\cdeanhar\git\datavis\config\locales\es.json for locale: es
Mon, 13 Oct 2014 01:31:42 GMT i18n:debug will write to c:\Users\cdeanhar\git\datavis\config\locales\fr.json
Mon, 13 Oct 2014 01:31:42 GMT i18n:debug read c:\Users\cdeanhar\git\datavis\config\locales\fr.json for locale: fr
Mon, 13 Oct 2014 01:31:42 GMT i18n:debug will write to c:\Users\cdeanhar\git\datavis\config\locales\de.json
Mon, 13 Oct 2014 01:31:42 GMT i18n:debug read c:\Users\cdeanhar\git\datavis\config\locales\de.json for locale: de
verbose: i18n hook loaded successfully.
verbose: session hook loaded successfully.
verbose: Loading app Gruntfile...
verbose: Tracking new grunt child process...
verbose: grunt hook loaded successfully.
verbose: http hook loaded successfully.
verbose: Overriding ejs engine config with ejslocals to implement layout support...
verbose: Configuring socket (ws://) server...
verbose: sockets hook loaded successfully.
verbose: Loading user hooks...
verbose: Located 0 user hook(s)...
verbose: views hook loaded successfully.
verbose: Setting default Express view engine to ejs...
verbose: Initialized 0 user hook(s)...
verbose: userhooks hook loaded successfully.
verbose: Loading adapter ( sails-disk ) for sdm from `node_modules` directory...
verbose: Starting ORM...
verbose: orm hook loaded successfully.
verbose: pubsub hook loaded successfully.
verbose: Built-in hooks are ready.
verbose: Instantiating registry...
verbose: Loading router...
verbose: Policy-controller bindings complete!
verbose: Waiting for all hooks to declare that they're ready...
verbose: All hooks were loaded successfully.
verbose: Starting app at c:\Users\cdeanhar\git\datavis...
verbose: Running the setup logic in `sails.config.bootstrap(cb)`...
verbose: Restricting access to explicit host: 0.0.0.0
info:
info:
info: Sails <|
info: v0.10.4 |\
info: /|.\
info: / || \
info: ,' |' \
info: .-'.-==|/_--'
info: `--'-------'
info: __---___--___---___--___---___--___
info: ____---___--___---___--___---___--___-__
info:
info: Server lifted in `c:\Users\cdeanhar\git\datavis`
info: To see your app, visit http://0.0.0.0:8181
info: To shut down Sails, press <CTRL> + C at any time.
verbose: browser client (v0.10.0) is trying to connect a socket...
verbose: Generated new session for socket.... { headers:
{ host: 'localhost:8181',
connection: 'keep-alive',
'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.101 Safari/537.36',
accept: '*/*',
referer: 'http://localhost:8181/',
'accept-encoding': 'gzip,deflate,sdch',
'accept-language': 'en-US,en;q=0.8',
cookie: 'search=ITSM; tab=0; sails.sid=s%3AIx4tfewY7LnBgXKFvlozSsyQ.qExipPSWxVgz7yG8wRgCq6h4DDgYIahIuQKTGTAAVMM; dev-perspective=App%20Owner; dev-focusME=2bc6168b249968d001249f6557760003' },
address: { address: '127.0.0.1', port: 53462 },
time: 'Sun Oct 12 2014 21:31:44 GMT-0400 (Eastern Daylight Time)',
query:
{ __sails_io_sdk_version: '0.10.0',
__sails_io_sdk_platform: 'browser',
__sails_io_sdk_language: 'javascript',
t: '1413163902883' },
url: '/socket.io/1/?__sails_io_sdk_version=0.10.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&t=1413163902883',
xdomain: false,
secure: undefined,
issued: 1413163904190,
cookie:
{ search: 'ITSM',
tab: '0',
'sails.sid': 's:Ix4tfewY7LnBgXKFvlozSsyQ.qExipPSWxVgz7yG8wRgCq6h4DDgYIahIuQKTGTAAVMM',
'dev-perspective': 'App Owner',
'dev-focusME': '2bc6168b249968d001249f6557760003' },
sessionID: 'Ix4tfewY7LnBgXKFvlozSsyQ',
session: { cookie: { httpOnly: true } } }
verbose: authorized
verbose: handshake authorized dS9obVLitVM6vFL4Ies8
verbose: Rendering view: "home/index" (located @ "c:\Users\cdeanhar\git\datavis\views\home\index")
verbose: • using configured layout:: layout (located @ "c:\Users\cdeanhar\git\datavis\views\layout")
verbose: Rendering view: "home/index" (located @ "c:\Users\cdeanhar\git\datavis\views\home\index")
verbose: • using configured layout:: layout (located @ "c:\Users\cdeanhar\git\datavis\views\layout")
verbose: browser client (v0.10.0) is trying to connect a socket...
verbose: Connected socket to existing session....
verbose: authorized
verbose: handshake authorized 1PVmZ4H7A9dDqfRzIes9
verbose: Sending 404 ("Not Found") response
verbose: setting request GET /socket.io/1/websocket/1PVmZ4H7A9dDqfRzIes9?__sails_io_sdk_version=0.10.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript
verbose: set heartbeat interval for client 1PVmZ4H7A9dDqfRzIes9
verbose: client authorized for
verbose: websocket writing 1::
verbose: A socket.io client (1PVmZ4H7A9dDqfRzIes9) connected successfully!
Loading first.. [object Object]
Loading more.. [object Object]
verbose: Sending 404 ("Not Found") response
最佳答案
TL;DR - Node 子进程派生“bug”,导致 Grunt 等待永远无法连接的调试器。
Sails 使用 child_process.fork() 生成一个单独的进程供 grunt 运行。
新流程inherits the node command line parameters of the calling process (fork的默认操作)。在你的情况下,“--debug-brk”。这会导致 grunt 的 Node 进程在第一行停止 - 等待调试器连接。
不幸的是,在Windows下,这个监听端口似乎是用SO_REUSEADDR打开的。这意味着两个进程可以监听同一个端口!
在我的测试中,我发现所有连接仅命中第一个开始监听的进程。我永远无法连接到子 Grunt 进程以允许继续执行。
我听说在较新版本的 Node(0.15?)中,每个分支都会从基础增量获取自己的端口。但我自己还没有测试过。
关于javascript - 使用 debug-brk 启动 Sails 不会运行 Grunt?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26367108/