Browse Source

`up kill` now works!

tags/v0.2.0
Muthu Kumar 7 years ago
parent
commit
28395af4c8
  1. 20
      README.md
  2. 1
      actions/createProxyServer.js
  3. 3
      actions/createStaticServer.js
  4. 15
      actions/killServer.js
  5. 30
      index.js
  6. 2
      package.json

20
README.md

@ -8,7 +8,7 @@
# up
> Current version: `up v.0.1.3 (Pre-Alpha)`
> Current version: `up v.0.1.4 (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!
@ -22,19 +22,7 @@ As of now, `up` only supports Debian and Ubuntu based distros. Support for more
You will need to have [_node JS_](https://nodejs.org) and [_nginx_](https://nginx.org) installed.
If you intend to install up for development, follow these instructions:
`git clone https://github.com/codefeathers/up-serve`
`cd up-serve`
`npm install`
`npm install -g`
> `up` is now available as a command.
Alternatively, to use `up` on to deploy servers install from npm:
Install `up` from npm:
`npm i -g up-serve`
@ -46,7 +34,7 @@ Alternatively, to use `up` on to deploy servers install from npm:
`up proxy <domain> <port>` - Create new proxy server listening at said port.
`up list` - List currently available servers.
`up list` - List currently available servers. (Doesn't work yet)
`up kill <domain>` - Kill the server for this domain.
@ -56,6 +44,8 @@ Alternatively, to use `up` on to deploy servers install from npm:
`up proxy example.com 8081` will create a reverse proxy listening at port 8081.
`up kill example.com`
## Contributors, Collaborators, and Guides
Plenty of people gave their time guiding me and shaping this tool.

1
actions/createProxyServer.js

@ -1,5 +1,6 @@
var fs = require('fs-extra');
var shell = require('shelljs');
var npath = require('../util/nginxPath');
var conf = require('../util/nginxConf');
var nginxReload = require('../util/nginxReload');

3
actions/createStaticServer.js

@ -1,8 +1,9 @@
var fs = require('fs-extra');
var shell = require('shelljs');
var path = require('path');
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());

15
actions/killServer.js

@ -0,0 +1,15 @@
var shell = require('shelljs');
var npath = require('../util/nginxPath');
var conf = require('../util/nginxConf');
var nginxReload = require('../util/nginxReload');
function killServer(domain) {
shell.rm('-rf', conf(npath.enabledSites(), domain));
shell.rm('-rf', conf(npath.availableSites(), domain));
shell.rm('-rf', npath.webRoot() + domain);
nginxReload();
}
module.exports = killServer;

30
index.js

@ -13,50 +13,52 @@ var requirements = require('./util/requirements')
// Requiring Actions
var createProxyServer = require('./actions/createProxyServer');
var createStaticServer = require('./actions/createStaticServer');
var killServer = require('./actions/killServer');
// 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')
.version('0.1.2');
program
.command('static <domain> [outPort]')
.description('Create a static server at this folder.')
.action(function (domain, outPort = 80) { //If outport is not given, 80 is set as default. Later, change this default to reflect nginx's settings.
if (!validate(domain, outPort)) return //Validates domain and outport, and if invalid, throws and returns.
createStaticServer(domain, outPort)
console.log("Done! Your static server has been set up!\nPoint your domain to this server and check " + chalk.cyan(domain) + " to verify!")
})
if (!validate(domain, outPort)) return; //Validates domain and outport, and if invalid, throws and returns.
createStaticServer(domain, outPort);
console.log("Done! Your static server has been set up!\nPoint your domain to this server and check " + chalk.cyan(domain) + " to verify!");
});
program
.command('proxy <domain> <inPort> [outPort]')
.description('Create a proxy server, listening at port number.')
.action(function (domain, inPort, outPort = "80") { //Inbound port is necessary, but outbound is set to 80 by default. Again, will change this to reflect nginx's settings.
if (!validate(domain, inPort, outPort)) return
createProxyServer(domain, inPort, outPort)
console.log("Done! Your reverse proxy server has been set up!\nPoint your domain to this server and check " + chalk.cyan(domain) + " to verify!")
})
if (!validate(domain, inPort, outPort)) return;
createProxyServer(domain, inPort, outPort);
console.log("Done! Your reverse proxy server has been set up!\nPoint your domain to this server and check " + chalk.cyan(domain) + " to verify!");
});
program
.command('list')
.description('List all available servers.')
.action(function () {
// Stuff happens here
})
});
program
.command('kill <domain>')
.description('Kill a server.')
.action(function (domain) {
// Stuff happens here
})
killServer(domain);
console.log("Done! Your server has been killed!\n");
});
program
.command('*') // This should pick invalid commands, but it doesn't, yet.
.action(function () {
console.log("Invalid command. Type " + chalk.cyan('up --help') + " for help.")
})
});
// Adds custom help text to the automatically generated help.
program.on('--help', function () {

2
package.json

@ -1,6 +1,6 @@
{
"name": "up-serve",
"version": "0.1.3",
"version": "0.1.4",
"description": "A cli tool to quickly create and manage nginx server blocks.",
"main": "index.js",
"scripts": {

Loading…
Cancel
Save