smartnginx/ts/smartnginx.classes.nginxconfig.ts
2016-07-08 04:24:07 +02:00

47 lines
1.3 KiB
TypeScript

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[] = [];
export class NginxConfig {
zones:NginxZone[] = [];
isDeployed:boolean = false;
constructor(){
};
// interact with Zones
addZone(zoneArg:NginxZone){
this.zones.push(zoneArg);
}
listZones():NginxZone[] {
return this.zones;
};
removeZones(zoneArg:NginxZone){
}
// handle deployment of zones
deploy(nginxRestartArg:boolean = false){
plugins.smartfile.fs.removeSync(paths.nginxConfigBase);
plugins.smartfile.fs.ensureDirSync(paths.nginxConfigBase);
plugins.smartfile.fs.ensureDirSync(paths.nginxZoneBase);
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);
};
};
};