add nginx child process
This commit is contained in:
@ -2,23 +2,53 @@ import * as plugins from "./smartnginx.plugins";
|
||||
import {NginxConfig} from "./smartnginx.classes.nginxconfig";
|
||||
import {NginxZone} from "./smartnginx.classes.nginxzone";
|
||||
|
||||
|
||||
let nginxChildProcess = undefined; // points to the nginx child process
|
||||
|
||||
|
||||
/**
|
||||
* starts nginx
|
||||
*/
|
||||
export let start = (configArg:NginxConfig) => {
|
||||
|
||||
let done = plugins.q.defer();
|
||||
if(typeof nginxChildProcess == "undefined"){
|
||||
nginxChildProcess = plugins.childProcess.exec("nginx",function(error, stdout, stderr){
|
||||
console.log(`stdout: ${stdout}`);
|
||||
console.log(`stderr: ${stderr}`);
|
||||
if (error !== null) {
|
||||
console.log(`exec error: ${error}`);
|
||||
}
|
||||
});
|
||||
};
|
||||
plugins.beautylog.info("started Nginx!");
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* restarts nginx
|
||||
*/
|
||||
export let restart = (configArg:NginxConfig) => {
|
||||
stop();
|
||||
start(configArg);
|
||||
return stop().then(
|
||||
() => {
|
||||
return start(configArg);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* stops nginx
|
||||
*/
|
||||
export let stop = () => {
|
||||
|
||||
let done = plugins.q.defer();
|
||||
if(typeof nginxChildProcess != "undefined"){
|
||||
nginxChildProcess.kill();
|
||||
plugins.beautylog.info("stopped Nginx!");
|
||||
} else {
|
||||
plugins.beautylog.log("nginx already stopped!");
|
||||
};
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,7 @@
|
||||
import "typings-global";
|
||||
export import beautylog = require("beautylog");
|
||||
export import cert = require("cert");
|
||||
export import childProcess = require("child_process");
|
||||
export import path = require("path");
|
||||
export import q = require("q");
|
||||
export let shelljs = require("shelljs");
|
||||
|
Reference in New Issue
Block a user