From cfa84fb9da0e466a90b5b1ad8a89d847d079fd8c Mon Sep 17 00:00:00 2001 From: Muthu Kumar Date: Fri, 3 Nov 2017 04:16:24 +0530 Subject: [PATCH] Setting nginx reload --- README.md | 2 +- actions/createProxyServer.js | 1 + actions/createStaticServer.js | 3 ++- index.js | 12 ++++++++++-- package.json | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9cf78c9..12a7cac 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ # up -> Current version: `up v.0.1.1 (Pre-Alpha)` +> Current version: `up v.0.1.2 (Pre-Alpha)` > Notes: `up` has landed in pre-alpha! 🎉 Changelog will be added from `up v.0.2.0` [(Alpha/MVP)](Roadmap.md)\ > ⚠️ ❌ `up` is still not ready for use yet! Do not attempt to use this in development or production until alpha! diff --git a/actions/createProxyServer.js b/actions/createProxyServer.js index 2fc5572..0e44040 100644 --- a/actions/createProxyServer.js +++ b/actions/createProxyServer.js @@ -26,6 +26,7 @@ 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"); }; module.exports = createProxyServer; \ No newline at end of file diff --git a/actions/createStaticServer.js b/actions/createStaticServer.js index 297f6f0..84e3d65 100644 --- a/actions/createStaticServer.js +++ b/actions/createStaticServer.js @@ -15,7 +15,7 @@ function createStaticServer(domain, outPort = 80) { " root " + npath.webRoot() + + domain + ";" + EOL + " index index.html index.htm;" + EOL + "" + EOL + - " server_name " + domain + EOL + + " server_name " + domain + ";" + EOL + " location / {" + EOL + " try_files $uri $uri/ =404;" + EOL + " }" + EOL + @@ -27,6 +27,7 @@ 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"); }; module.exports = createStaticServer; \ No newline at end of file diff --git a/index.js b/index.js index 5a0f17a..55a8cb3 100644 --- a/index.js +++ b/index.js @@ -18,7 +18,7 @@ var createStaticServer = require('./actions/createStaticServer'); // 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.0.1') + .version('0.1.2') program .command('static [outPort]') @@ -72,4 +72,12 @@ program.on('--help', function () { }); // Parses commands passed to `up` and chooses one of the above commands. -program.parse(process.argv); \ No newline at end of file +program.parse(process.argv); + +try { + exec("nginx -t && service reload nginx"); +} + +catch { + console.log("nginx configuration failed! Unable to reload nginx. Check configuration manually!") +} \ No newline at end of file diff --git a/package.json b/package.json index 9e4b8e0..be70580 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "up-serve", - "version": "0.1.0", + "version": "0.1.2", "description": "A cli tool to quickly create and manage nginx server blocks.", "main": "index.js", "scripts": {