add nginx child process
This commit is contained in:
parent
1f2105f75e
commit
871ff06040
11
dist/smartnginx.command.d.ts
vendored
11
dist/smartnginx.command.d.ts
vendored
@ -1,13 +1,18 @@
|
|||||||
|
/// <reference types="q" />
|
||||||
|
import * as plugins from "./smartnginx.plugins";
|
||||||
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
import { NginxConfig } from "./smartnginx.classes.nginxconfig";
|
||||||
/**
|
/**
|
||||||
* starts nginx
|
* starts nginx
|
||||||
*/
|
*/
|
||||||
export declare let start: (configArg: NginxConfig) => void;
|
export declare let start: (configArg: NginxConfig) => plugins.q.Promise<{}>;
|
||||||
export declare let restart: (configArg: NginxConfig) => void;
|
/**
|
||||||
|
* restarts nginx
|
||||||
|
*/
|
||||||
|
export declare let restart: (configArg: NginxConfig) => plugins.q.Promise<{}>;
|
||||||
/**
|
/**
|
||||||
* stops nginx
|
* stops nginx
|
||||||
*/
|
*/
|
||||||
export declare let stop: () => void;
|
export declare let stop: () => plugins.q.Promise<{}>;
|
||||||
/**
|
/**
|
||||||
* checks if nginx is in path
|
* checks if nginx is in path
|
||||||
*/
|
*/
|
||||||
|
37
dist/smartnginx.command.js
vendored
37
dist/smartnginx.command.js
vendored
@ -1,17 +1,48 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
var plugins = require("./smartnginx.plugins");
|
||||||
|
var nginxChildProcess = undefined; // points to the nginx child process
|
||||||
/**
|
/**
|
||||||
* starts nginx
|
* starts nginx
|
||||||
*/
|
*/
|
||||||
exports.start = function (configArg) {
|
exports.start = function (configArg) {
|
||||||
|
var 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
|
||||||
|
*/
|
||||||
exports.restart = function (configArg) {
|
exports.restart = function (configArg) {
|
||||||
exports.stop();
|
return exports.stop().then(function () {
|
||||||
exports.start(configArg);
|
return exports.start(configArg);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* stops nginx
|
* stops nginx
|
||||||
*/
|
*/
|
||||||
exports.stop = function () {
|
exports.stop = function () {
|
||||||
|
var 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;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* checks if nginx is in path
|
* checks if nginx is in path
|
||||||
@ -19,4 +50,4 @@ exports.stop = function () {
|
|||||||
exports.check = function () {
|
exports.check = function () {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5jb21tYW5kLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5jb21tYW5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFJQTs7R0FFRztBQUNRLGFBQUssR0FBRyxVQUFDLFNBQXFCO0FBRXpDLENBQUMsQ0FBQztBQUVTLGVBQU8sR0FBRyxVQUFDLFNBQXFCO0lBQ3ZDLFlBQUksRUFBRSxDQUFDO0lBQ1AsYUFBSyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQ3JCLENBQUMsQ0FBQTtBQ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
|
2
dist/smartnginx.plugins.d.ts
vendored
2
dist/smartnginx.plugins.d.ts
vendored
@ -1,5 +1,7 @@
|
|||||||
import "typings-global";
|
import "typings-global";
|
||||||
|
export import beautylog = require("beautylog");
|
||||||
export import cert = require("cert");
|
export import cert = require("cert");
|
||||||
|
export import childProcess = require("child_process");
|
||||||
export import path = require("path");
|
export import path = require("path");
|
||||||
export import q = require("q");
|
export import q = require("q");
|
||||||
export declare let shelljs: any;
|
export declare let shelljs: any;
|
||||||
|
4
dist/smartnginx.plugins.js
vendored
4
dist/smartnginx.plugins.js
vendored
@ -1,9 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
require("typings-global");
|
require("typings-global");
|
||||||
|
exports.beautylog = require("beautylog");
|
||||||
exports.cert = require("cert");
|
exports.cert = require("cert");
|
||||||
|
exports.childProcess = require("child_process");
|
||||||
exports.path = require("path");
|
exports.path = require("path");
|
||||||
exports.q = require("q");
|
exports.q = require("q");
|
||||||
exports.shelljs = require("shelljs");
|
exports.shelljs = require("shelljs");
|
||||||
exports.smartfile = require("smartfile");
|
exports.smartfile = require("smartfile");
|
||||||
exports.smartstring = require("smartstring");
|
exports.smartstring = require("smartstring");
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDdkIsWUFBSSxXQUFXLE1BQU0sQ0FBQyxDQUFDO0FBQ3ZCLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNwQixlQUFPLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzFCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRuZ2lueC5wbHVnaW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRuZ2lueC5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDVixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixvQkFBWSxXQUFXLGVBQWUsQ0FBQyxDQUFDO0FBQ3hDLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDcEIsZUFBTyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQztBQUMxQixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDO0FBQ2pDLG1CQUFXLFdBQVcsYUFBYSxDQUFDLENBQUMifQ==
|
@ -23,6 +23,7 @@
|
|||||||
"homepage": "https://gitlab.com/pushrocks/smartnginx#README",
|
"homepage": "https://gitlab.com/pushrocks/smartnginx#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/q": "0.0.25-alpha",
|
"@types/q": "0.0.25-alpha",
|
||||||
|
"beautylog": "^5.0.13",
|
||||||
"cert": "0.0.13",
|
"cert": "0.0.13",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"shelljs": "^0.7.0",
|
"shelljs": "^0.7.0",
|
||||||
|
@ -2,23 +2,53 @@ import * as plugins from "./smartnginx.plugins";
|
|||||||
import {NginxConfig} from "./smartnginx.classes.nginxconfig";
|
import {NginxConfig} from "./smartnginx.classes.nginxconfig";
|
||||||
import {NginxZone} from "./smartnginx.classes.nginxzone";
|
import {NginxZone} from "./smartnginx.classes.nginxzone";
|
||||||
|
|
||||||
|
|
||||||
|
let nginxChildProcess = undefined; // points to the nginx child process
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* starts nginx
|
* starts nginx
|
||||||
*/
|
*/
|
||||||
export let start = (configArg:NginxConfig) => {
|
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) => {
|
export let restart = (configArg:NginxConfig) => {
|
||||||
stop();
|
return stop().then(
|
||||||
start(configArg);
|
() => {
|
||||||
|
return start(configArg);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* stops nginx
|
* stops nginx
|
||||||
*/
|
*/
|
||||||
export let stop = () => {
|
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";
|
import "typings-global";
|
||||||
|
export import beautylog = require("beautylog");
|
||||||
export import cert = require("cert");
|
export import cert = require("cert");
|
||||||
|
export import childProcess = require("child_process");
|
||||||
export import path = require("path");
|
export import path = require("path");
|
||||||
export import q = require("q");
|
export import q = require("q");
|
||||||
export let shelljs = require("shelljs");
|
export let shelljs = require("shelljs");
|
||||||
|
Loading…
Reference in New Issue
Block a user