如下:

nodeServer.js

'use strict';
const http = require('http');

const server = http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    res.end('Hello World\n');
});

const port = 8361;
server.listen(port);

console.log(`Server is running at http://127.0.0.1:${port}/`);

 

node nodeServer

 

下面用pm2管理,及常用

pm2 start nodeServer.js // 启动管理

pm2 工具来管理 node 服务端

pm2 list // 或者 pm2 l 简写 // 查看所用已启动项目

pm2 restart xxx // 重启

pm2 stop xxx // 停止

pm2 delete xxx // 删除

 

当然也可配置json文件,来启用管理

PM2 文档: http://pm2.keymetrics.io/docs/usage/quick-start/#usage

 

相关文章:

  • 2021-06-30
  • 2021-10-02
  • 2021-10-16
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2021-04-01
猜你喜欢
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2022-02-26
  • 2021-07-15
相关资源
相似解决方案