-
Notifications
You must be signed in to change notification settings - Fork 4
/
reset.js
29 lines (25 loc) · 865 Bytes
/
reset.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const async = require('async');
const debug = require('debug')('ngineer:reset');
const exec = require('child_process').exec;
const path = require('path');
const fs = require('fs');
const config = require('./config');
module.exports = function(ngineer, basePath, opts) {
return function(callback) {
const configPath = path.join(basePath, 'conf');
fs.readdir(configPath, function(err, files) {
const filesToDelete = files.map(function(filename) {
return path.join(configPath, filename);
});
debug('deleting config files: ', files);
async.forEach(filesToDelete || [], fs.unlink, function(err) {
if (err) {
debug('could not delete config files, aborting stop');
return callback(err);
}
debug('attempting to stop nginx');
ngineer.stop(callback);
});
});
};
};