Browse Source

Bug that disallowed nginx reload has been squashed.

tags/v0.2.0
Muthu Kumar 7 years ago
parent
commit
d29893aea1
  1. 4
      actions/createProxyServer.js
  2. 4
      actions/createStaticServer.js
  3. 13
      index.js
  4. 2
      package-lock.json
  5. 14
      util/nginxReload.js

4
actions/createProxyServer.js

@ -2,6 +2,7 @@ var fs = require('fs-extra');
var shell = require('shelljs');
var npath = require('../util/nginxPath');
var conf = require('../util/nginxConf');
var nginxReload = require('../util/nginxReload');
var { EOL } = require('os'); // \n if used on Linux, \r\n if used on Windows.
@ -26,7 +27,8 @@ function createProxyServer(domain, inPort, outPort) {
)
shell.mkdir('-p', npath.enabledSites()); // Creates directory if doesn't exist
shell.ln('-sf', conf(npath.availableSites(), domain), conf(npath.enabledSites(), domain)); // Symlink the conf file from sites-available to sites-enabled
exec("service nginx reload");
nginxReload();
};
module.exports = createProxyServer;

4
actions/createStaticServer.js

@ -3,6 +3,7 @@ var shell = require('shelljs');
var npath = require('../util/nginxPath');
var conf = require('../util/nginxConf');
var path = require('path');
var nginxReload = require('../util/nginxReload');
var currentPath = path.normalize(process.cwd());
var { EOL } = require('os'); // \n if used on Linux, \r\n if used on Windows.
@ -27,7 +28,8 @@ function createStaticServer(domain, outPort = 80) {
shell.rm('-rf', npath.webRoot() + domain); // Removes domain from webroot if exists
shell.mkdir('-p', npath.webRoot()); // Creating the nginx www path if it doesn't exist so symlink doesn't fail
shell.ln('-sf', currentPath, npath.webRoot() + domain); // Symlink current directory to nginx's web root
exec("service nginx reload");
nginxReload();
};
module.exports = createStaticServer;

13
index.js

@ -5,9 +5,6 @@ var program = require('commander');
var shell = require('shelljs');
var fs = require('fs-extra');
var chalk = require('chalk');
var { exec } = require('child_process');
var nginxReload = exec("nginx -t && service reload nginx");
// Requiring utils
var validate = require('./util/validate');
@ -18,7 +15,7 @@ var createProxyServer = require('./actions/createProxyServer');
var createStaticServer = require('./actions/createStaticServer');
// Check for requirements such as OS version and nginx install. Throw and exit if requirements not found. #Roadmap: Add ability to satisfy any possible requirements.
// requirements(); // Comment in development and uncomment this line in production. This should check whether the OS is compatible with this version of `up`
requirements(); // Comment in development and uncomment this line in production. This should check whether the OS is compatible with this version of `up`
program
.version('0.1.2')
@ -76,11 +73,3 @@ program.on('--help', function () {
// Parses commands passed to `up` and chooses one of the above commands.
program.parse(process.argv);
try {
nginxReload();
}
catch (e) {
console.log("nginx configuration failed! Unable to reload nginx. Check configuration manually!")
}

2
package-lock.json

@ -1,6 +1,6 @@
{
"name": "up-serve",
"version": "0.0.1",
"version": "0.1.3",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

14
util/nginxReload.js

@ -0,0 +1,14 @@
var { exec } = require('child_process');
function nginxReload() {
exec('service nginx reload', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
});
}
module.exports = nginxReload;
Loading…
Cancel
Save