now writing configs properly to disk

This commit is contained in:
LosslessBot
2016-07-08 04:24:07 +02:00
parent 9864dcc56a
commit 43e8549042
12 changed files with 54 additions and 17 deletions

View File

@@ -6,7 +6,7 @@ import {NginxZone} from "./smartnginx.classes.nginxzone";
let allConfigs:NginxConfig[] = [];
export class NginxConfig {
zones:NginxZone[];
zones:NginxZone[] = [];
isDeployed:boolean = false;
constructor(){
@@ -14,7 +14,7 @@ export class NginxConfig {
// interact with Zones
addZone(zoneArg:NginxZone){
this.zones.push(zoneArg);
}
listZones():NginxZone[] {
return this.zones;
@@ -25,8 +25,9 @@ export class NginxConfig {
// handle deployment of zones
deploy(nginxRestartArg:boolean = false){
plugins.smartfile.fs.remove(paths.nginxConfigBase);
plugins.smartfile.fs.ensureDir(paths.nginxConfigBase);
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;
};
@@ -40,7 +41,6 @@ export class NginxConfig {
);
if(nginxRestartArg){
command.restart(this);
}
};
};
};

View File

@@ -9,12 +9,17 @@ export enum zoneTypes {
export class NginxZone {
zoneName:string; // the zone name e.g. domain name
type:zoneTypes;
destination:string;
configString:string; // the actual zone config file as string
constructor(optionsArg:{
zoneName:string,
type:zoneTypes,
destination:string
}){
this.zoneName = optionsArg.zoneName;
this.type = optionsArg.type;
this.destination = optionsArg.destination;
this.configString = snippets.getZoneConfigString(optionsArg.zoneName,optionsArg.destination);
};
deploy(){

View File

@@ -67,6 +67,7 @@ export let getBaseConfigString = () => {
}
daemon off;
`);
return baseConfig;
}