node.js中创建并启动了一个http server模块后,日后热配置时如何获取它?
黄舟
黄舟 2017-04-17 13:18:28
0
3
707

直接x=require(http).createServer.listen的话,哪怕是全局变量也只存在于那个进程中。再次打开node.exe是一个新的进程,变量不存在。请教一旦关了命令行界面,如何才能再访问当时启动的上下文去热操作那个x?总不能每次都重启吧

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(3)
小葫芦

Global variables only exist in one process and cannot be called across processes. If you want to debug, write it directly in the js file. After modification, you can only restart. js is a 'semi-compiled' language.

伊谢尔伦

Used under linuxnohup node xxxx.js &
Used under windowsstart node xxx.js

伊谢尔伦

Configuration like this can be done not in global variables, but in the file system

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template