Browse Source

Setting nginx reload

tags/v0.2.0
Muthu Kumar 7 years ago
parent
commit
cfa84fb9da
  1. 2
      README.md
  2. 1
      actions/createProxyServer.js
  3. 3
      actions/createStaticServer.js
  4. 12
      index.js
  5. 2
      package.json

2
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!

1
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;

3
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;

12
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 <domain> [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);
program.parse(process.argv);
try {
exec("nginx -t && service reload nginx");
}
catch {
console.log("nginx configuration failed! Unable to reload nginx. Check configuration manually!")
}

2
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": {

Loading…
Cancel
Save