Browse Source

`up kill` works, with known exceptions:

The code block that removes a server block if it exists does not work yet. Appears twice in `listFile.js` - `appendToList` and `removeFromList`
pull/3/head
Muthu Kumar 7 years ago
parent
commit
23fd1b9e43
  1. 1
      actions/createStaticServer.js
  2. 2
      actions/killServer.js
  3. 17
      utils/listFile.js

1
actions/createStaticServer.js

@ -5,6 +5,7 @@ var path = require('path');
var npath = require('../utils/nginxPath');
var conf = require('../utils/nginxConf');
var nginxReload = require('../utils/nginxReload');
var appendToList = require('../utils/listFile').appendToList;
var currentPath = path.normalize(process.cwd());
var EOL = require('os').EOL; // \n if used on Linux, \r\n if used on Windows.

2
actions/killServer.js

@ -3,6 +3,7 @@ var shell = require('shelljs');
var npath = require('../utils/nginxPath');
var conf = require('../utils/nginxConf');
var nginxReload = require('../utils/nginxReload');
var removeFromList = require('../utils/listFile').removeFromList;
function killServer(domain, outPort) {
shell.rm('-rf', conf(npath.enabledSites(), domain, outPort));
@ -10,6 +11,7 @@ function killServer(domain, outPort) {
shell.rm('-rf', npath.webRootDomain(domain, outPort));
nginxReload();
removeFromList(domain, outPort);
}
module.exports = killServer;

17
utils/listFile.js

@ -31,7 +31,7 @@ function appendToList(domain, outPort, inPort) {
jsonFile = JSON.parse(jsonFile);
for (block in jsonFile) {
if (block.domain == domain && block.domain.outPort == outPort) {
if (block[domain] == domain && block[domain].outPort == outPort) {
delete jsonFile.block;
return;
}
@ -45,11 +45,6 @@ function appendToList(domain, outPort, inPort) {
jsonFile = beautifyJSON(jsonFile);
}
fs.writeFileSync(listFilePath, jsonFile);
}
function readServers () {
return JSON.parse(fs.readFileSync(listFilePath));
}
function removeFromList (domain, outPort) {
@ -59,8 +54,9 @@ function removeFromList (domain, outPort) {
jsonFile = JSON.parse(jsonFile);
for (block in jsonFile) {
if (block.domain == domain && block.domain.outPort == outPort) {
if (block[domain] == domain && block[domain].outPort == outPort) {
delete jsonFile.block;
console.log('\nDomain was deleted successfully.\n');
return;
}
}
@ -73,5 +69,10 @@ function removeFromList (domain, outPort) {
fs.writeFileSync(listFilePath, jsonFile);
}
function readServers () {
return JSON.parse(fs.readFileSync(listFilePath));
}
module.exports.appendToList = appendToList;
module.exports.readServers = readServers;
module.exports.readServers = readServers;
module.exports.removeFromList = removeFromList;
Loading…
Cancel
Save