GitBook:启动多实例进程失败:listen EADDRINUSE :::35729
1.报错
目录结构:
/home/test1280 tree $HOME -L 2
/home/test1280
├── book1
│ ├── README.md
│ └── SUMMARY.md
└── book2
├── README.md
└── SUMMARY.md
2 directories, 4 files
在一个主机中启动多个gitbook进程提供服务。
第一个gitbook实例监听4000,启动正常:
/home/test1280 cd book1 && gitbook serve --port=4000
Live reload server started on port: 35729
Press CTRL+C to quit ...
info: 7 plugins are installed
info: loading plugin "livereload"... OK
info: loading plugin "highlight"... OK
info: loading plugin "search"... OK
info: loading plugin "lunr"... OK
info: loading plugin "sharing"... OK
info: loading plugin "fontsettings"... OK
info: loading plugin "theme-default"... OK
info: found 1 pages
info: found 0 asset files
info: >> generation finished with success in 0.7s !
Starting server ...
Serving book on http://localhost:4000
第二个gitbook实例监听4001,启动异常:
/home/test1280 cd book2 && gitbook serve --port=4001
... Uhoh. Got error listen EADDRINUSE :::35729 ...
Error: listen EADDRINUSE :::35729
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at Server._listen2 (net.js:1271:14)
at listen (net.js:1307:10)
at Server.listen (net.js:1403:5)
at Server.listen (/home/test1280/.gitbook/versions/3.2.3/node_modules/tiny-lr/lib/server.js:164:15

在同一个主机上启动多个GitBook实例时遇到端口冲突问题,具体表现为第二个实例启动时监听端口35729失败,错误为EADDRINUSE。原因是GitBook进程除了监听指定的HTTP端口外,还会占用一个 Livereload 服务端口。通过`gitbook serve`命令的`--lrport`选项可以指定 Livereload 端口,从而解决冲突。例如,分别设置不同的lrport值如4100和4101,成功启动了两个独立的GitBook实例。
最低0.47元/天 解锁文章
2401

被折叠的 条评论
为什么被折叠?



