now writing configs properly to disk
This commit is contained in:
@@ -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);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
|
@@ -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(){
|
||||
|
@@ -67,6 +67,7 @@ export let getBaseConfigString = () => {
|
||||
}
|
||||
daemon off;
|
||||
`);
|
||||
return baseConfig;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user