简体   繁体   English

Express如何运作?

[英]How does Express work?

I am learning MEAN stack and learnt how it starts like, 我正在学习MEAN堆栈,并了解了它的开始方式,

var http = require('http'),
    express = require('exress'),
    app = express();
app.listen(8080);

and I type node example.js on terminal then I can check it on the Web browser. 然后在终端上键入node example.js,然后可以在Web浏览器上进行检查。 If I stop process on terminal(in my case, it is ctrl + C), it does not show up on the Web browser. 如果我在终端上停止进程(在我的情况下是ctrl + C),则该进程不会显示在Web浏览器上。 So I wonder if I use MEAN stack cloud server(like aws or digitalocean), should I have to keep terminal which connects cloud server on all the time, so that users can connect my website 24/7 via typing domain? 因此,我想知道是否使用MEAN堆栈云服务器(例如AWS或digitalocean),是否应该一直保持连接云服务器的终端,以便用户可以通过键入域24/7连接我的网站? Thanks! 谢谢!

You should run node app process in the background , you run command line as below: 您应该在后台运行节点应用程序进程,并按如下所示运行命令行:

$nohup node simple-server.js > output.log &

Or you can use forever: http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever/ 或者您可以永远使用: http : //blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM