start storing configs to FS
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import * as plugins from "./smartnginx.plugins";
|
||||
import * as paths from "./smartnginx.paths";
|
||||
import * as command from "./smartnginx.command";
|
||||
import * as snippets from "./smartnginx.snippets"
|
||||
import {NginxZone} from "./smartnginx.classes.nginxzone";
|
||||
let allConfigs:NginxConfig[] = [];
|
||||
|
||||
@ -24,15 +25,19 @@ export class NginxConfig {
|
||||
|
||||
// handle deployment of zones
|
||||
deploy(nginxRestartArg:boolean = false){
|
||||
plugins.smartfile.fs.remove(paths.nginxZoneBase);
|
||||
plugins.smartfile.fs.ensureDir(paths.nginxZoneBase);
|
||||
plugins.smartfile.fs.remove(paths.nginxConfigBase);
|
||||
plugins.smartfile.fs.ensureDir(paths.nginxConfigBase);
|
||||
for(let config of allConfigs){
|
||||
config.isDeployed = false;
|
||||
};
|
||||
this.isDeployed = true;
|
||||
for(let zone of this.zones){
|
||||
zone.deploy();
|
||||
}
|
||||
};
|
||||
plugins.smartfile.memory.toFsSync(
|
||||
snippets.getBaseConfigString(),
|
||||
plugins.path.join(paths.nginxConfigBase,"nginx.conf")
|
||||
);
|
||||
if(nginxRestartArg){
|
||||
command.restart(this);
|
||||
}
|
||||
|
@ -3,4 +3,5 @@ export import cert = require("cert");
|
||||
export import path = require("path");
|
||||
export import q = require("q");
|
||||
export let shelljs = require("shelljs");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartstring = require("smartstring");
|
@ -1,5 +1,6 @@
|
||||
import * as plugins from "./smartnginx.plugins";
|
||||
export let getBaseConfigString = () => {
|
||||
let baseConfig = `
|
||||
let baseConfig = plugins.smartstring.indent.normalize(`
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
@ -65,12 +66,12 @@ export let getBaseConfigString = () => {
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
||||
daemon off;
|
||||
`;
|
||||
`);
|
||||
}
|
||||
|
||||
|
||||
export let getZoneConfigString = (zoneNameArg:string,destinationIpArg:string) => {
|
||||
let zoneConfig = `
|
||||
let zoneConfig = plugins.smartstring.indent.normalize(`
|
||||
upstream ${zoneNameArg} {
|
||||
server ${destinationIpArg};
|
||||
}
|
||||
@ -95,7 +96,7 @@ export let getZoneConfigString = (zoneNameArg:string,destinationIpArg:string) =>
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
`;
|
||||
`);
|
||||
return zoneConfig;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user