简体   繁体   English

为什么Apache服务器每天自动启动并停止nodeJs?

[英]Why Apache server start automatically everyday and it stops the nodeJs?

I am working in MEAN STACK application, I face one issue in a live site. 我在MEAN STACK应用程序中工作,我在一个实时站点中遇到一个问题。
In my live web site, I have stop Apache server and run nodeJs by using pm2. 在我的实时网站上,我已经停止了Apache服务器并使用pm2运行nodeJs。
Once nodeJs started by pm2, my site running very well, but after every next day, Apache server automatically starts and my nodeJs site stop. 一旦pm2启动nodeJs,我的站点就运行良好,但是隔天,Apache服务器自动启动,而我的nodeJs站点停止。 After stopping of Apache server the nodeJS works fine. 停止Apache服务器后,nodeJS正常运行。

app.js app.js

"use strict";
var logger = require("./config/log");
var express = require("express");
var https = require('https');
var http = require("http");
var fs = require('fs');
var app = express();
var exec = require('child_process').exec;
var config, hostName, sslOptions, httpServer, callSocketDir;
/**
* @description all process variables
*/
require("./config/vars")(app, fs);

config = require("./config/config.js")(app, express);
callSocketDir = './socket';

sslOptions = {
    key: fs.readFileSync(global.hzConfig.privateKey),
    cert: fs.readFileSync(global.hzConfig.certificate),
    passphrase: global.hzConfig.passPhrase
};
httpServer = https.createServer(sslOptions, app).listen(global.hzConfig.port,function (req, res) {
    logger.log("info", 'my site is listening on ssl port ' + global.hzConfig.port + ", proccess id is " + process.pid + '!');
    initEmailServer();
});

require(callSocketDir)(app, httpServer);  

Stop apache server 停止Apache服务器

/usr/local/apache/bin/apachectl stop

Start nodejs server 启动nodejs服务器

pm2 start httpsServer.js 

dependencies 依赖

"express"  => "version" : "4.13.4",  
"nodeJs"   => "version" : "v7.4.0",  
"https"    => "version" : "^1.0.0"

Please give me a proper guideline for this issue. 请给我有关此问题的正确指导。 在此处输入图片说明

Basically the Apache server and nodejs server might be on the same port for example if node js server running on port 80 and your Apache server to port is also running port 80 基本上,Apache服务器和nodejs服务器可能在同一端口上,例如,如果node js服务器在端口80上运行,并且您的Apache服务器到该端口也在端口80上运行

try and set one of the server to port 8080 尝试将服务器之一设置为端口8080

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

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