Giter Site home page Giter Site logo

oothkoo / supervizer Goto Github PK

View Code? Open in Web Editor NEW
295.0 16.0 21.0 365 KB

The most simple NodeJS application manager with RESTful API.

License: MIT License

JavaScript 100.00%
systemd upstart sysvinit javascript cli application-management management fault-tolerant sysadmin tools monitoring process-manager forever process-configuration pm2 supervisord clustering cluster master server

supervizer's Introduction

Supervizer Travis Status SlugBay Badge

Stars Latest Stable Version NPM Downloads NPM Downloads

A NodeJS manager to spawn/stop/manage node application.

  supervizer list

List command

  supervizer monit

Monit command

  supervizer get myApp

Get command

  supervizer-master

Get command

Features

  • Start/Stop/Restart a node application
  • Grouping applications
  • Start/Stop/Restart a application group
  • Hot change application parameters (env, host, port, logs) in realtime ;-)
  • Keep alive/Restart a application when it crash
  • Monitoring application resources (restart count, uptime, memory, cpu etc..)
  • Watch directories/files changes to restart application
  • Full RESTfull API management via HTTP/S
  • Application LOG files process management
  • Application PID files process management
  • User execution process management by uid:gid
  • Load/Save all application configurations from/to JSON config file

Installation (module)

To install node supervizer module from npm repository :

  npm install -g supervizer

Or from source:

  git clone git://github.com/oOthkOo/supervizer.git
  cd supervizer
  npm link -g

And run this command to start supervizer master server :

  supervizer-server

Installation (master)

To install supervizer master as a daemon/service :

On Linux :

With Sysvinit - (https://help.ubuntu.com/community/UbuntuBootupHowto).
With Upstart - (http://upstart.ubuntu.com/getting-started.html).
With Systemd - (https://wiki.ubuntu.com/SystemdForUpstartUsers).

Configuration (apps)

To make your nodeJS Application fully compatible with Supervizer, you must follow this code example to retrieve host and port parameters :

var host = process.argv[2] || '0.0.0.0';
var port = process.argv[3] || '5000';

For example, if you use expressjs framework :

var express = require('express');
var server = express();

server.use(express.static(__dirname + '/public'));
server.use(express.logger());

server.get('/', function(req, res) {  	
	res.end('Hello word!');
});

server.get('*', function(req, res) {
  	res.send('Not Found!', 404);
});

server.use(function(err, req, res, next) {  	
  	res.send(500, 'Something broke!');
	console.error(err.stack);
});

var host = process.argv[2] || '0.0.0.0';
var port = process.argv[3] || '5000';

server.listen(port, host);
console.log('Listening on port ' + port);

Usage (Summary)

Add your application :

  supervizer add --name myApp --group myGroup --script /path/to/script.js
  --host localhost --port 3000 --watch /path/to/watch --log /path/to/logfile.log

Start your application :

  supervizer start --name myApp

Stop your application :

  supervizer stop --name myApp

Update your application parameters :

  supervizer set myApp --port 3001

Save all your applications :

  supervizer save --config /path/to/apps.json

Load all your applications :

  supervizer load --config /path/to/apps.json

Start all your applications :

  supervizer startAll  

Start all applications by group:

  supervizer startAll --group myGroup

Disable your application :

  supervizer disable myApp

Security (Authentication)

Enable authentication mode :

  supervizer secure enable --auth myNewUserName:myNewPassword

Restart your application with authentication :

  supervizer restart --name myApp --auth myUserName:myPassword

Disable authentication mode :

  supervizer secure disable --auth myUserName:myPassword

Update your credentials :

  supervizer secure disable --auth myOldUserName:myOldPassword
  supervizer secure enable --auth myNewUserName:myNewPassword

Usage (Complete)

  supervizer [command] <options>

  Commands:

    install                install supervizer as daemon
    uninstall              uninstall supervizer as daemon
    load                   load all applications from a JSON config file
    save                   save all applications to a JSON config file
    add                    add an application
    remove                 remove an application
    start                  start an application
    startAll               start all applications
    stop                   stop an application
    stopAll                stop all applications
    restart                restart an application
    restartAll             restart all applications
    list                   list all applications
    monit                  monitor all applications
    secure                 create/update/remove security authentication
    enable <name>          enable an application
    enableAll              enable all applications
    disable <name>         disable an application
    disableAll             disable all applications
    set <name>             setting application property value
    get <name>             getting application properties values

  Options:

    -h, --help                  output usage information
    -V, --version               output the version number
    -v --verbose                display verbose data
    -n --name <string>          specify application name
    -z --env <string>           specify comma separated environment variables
    -x --params <string>        specify node command line extra parameters
    -r --run <user:group>       specify user uid:gid to run application
    -g --group <string>         specify application group
    -s --script <path>          specify application main script
    -l --log <file>             specify application log output file
    -t --pid <file>             specify application pid file
    -k --keep <yes/no>          keep alive application (default:yes)
    -t --attempt <number>       max restart to keep alive (default:3)
    -w --watch <path>           specify path to watch
    -e --exclude <regex,regex>  specify regexes to exclude paths
    -h --host <address>         specify address to bind
    -p --port <port>            specify port to bind
    -a --auth <user:password>   specify user/password to use
    -c --config <file>          specify JSON config file to load/save

API endpoints

Supervizer master server has an RESTfull HTTP interface wich allow you to control it remotely ;-)

COMMANDs VERBs URIs Descriptions
GET / Show server banner
load POST /config/load Load all applications from file
save POST /config/save Save all applications to file
add PUT /apps Add an application to run
remove DELETE /apps Stop and Remove an application
start POST /app/start Start an application
startAll POST /apps/start Start all applications
stop POST /app/stop Stop an application
stopAll POST /apps/stop Stop all applications
restart POST /app/restart Restart an application
restartAll POST /apps/restart Restart all applications
list POST /apps/list List all applications
monit POST /apps/monit Monitor all applications
list POST /secure enable/disable authentication
enable POST /app/enable Enable an application
enableAll POST /apps/enable Enable all applications
disable POST /app/disable Disable an application
disableAll POST /apps/disable Disable all applications
set POST /app Set an application property
get GET /app Get an application property

TODOs (commands)

Theses commands actually doesn't work, but you can install easily Supervizer master as a service by Systemd, Upstart, Sysvinit or other.

* install
* uninstall

supervizer's People

Contributors

oothkoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

supervizer's Issues

Exclude RegEx not working

Whenever I add a regex for the exclude watch flag it gives me an error:

[2013-12-05 04:13:40]: [ERROR]: A fatal error occured.
TypeError: Object logs has no method 'push'
    at start (/usr/lib/node_modules/supervizer/lib/main.js:594:24)
    at Object.startAll (/usr/lib/node_modules/supervizer/lib/main.js:657:17)
    at /usr/lib/node_modules/supervizer/bin/supervizer-server:118:30
    at callbacks (/usr/lib/node_modules/supervizer/node_modules/express/lib/router/index.js:161:37)
    at param (/usr/lib/node_modules/supervizer/node_modules/express/lib/router/index.js:135:11)
    at pass (/usr/lib/node_modules/supervizer/node_modules/express/lib/router/index.js:142:5)
    at Router._dispatch (/usr/lib/node_modules/supervizer/node_modules/express/lib/router/index.js:170:5)
    at Object.router (/usr/lib/node_modules/supervizer/node_modules/express/lib/router/index.js:33:10)
    at next (/usr/lib/node_modules/supervizer/node_modules/express/node_modules/connect/lib/proto.js:190:15)
    at multipart (/usr/lib/node_modules/supervizer/node_modules/express/node_modules/connect/lib/middleware/multipart.js:60:27)

Could you give me an example of how to use the functionality? Right now I'm simply passing --watch "/home/me" --exclude "/home/me/logs.*"

Add node_env option

Hello, it is possible to add NODE_ENV option on register NodeJS app to set the app environment like local, production, development ?

Normally, i launch my scripts like this :

NODE_ENV=local nodejs server.js

Fails on Windows

> [email protected] install C:\Users\User\AppData\Roaming\npm\node_modules\supervizer\node_modules\synchronize\node_modules\f
ibers
> node ./build.js

`win32-x64-v8-3.14` exists; testing
Binary is fine; exiting
C:\Users\User\AppData\Roaming\npm\supervizer -> C:\Users\User\AppData\Roaming\npm\node_modules\supervizer\bin\supervizer
-client
C:\Users\User\AppData\Roaming\npm\supervizer-server -> C:\Users\User\AppData\Roaming\npm\node_modules\supervizer\bin\sup
ervizer-server
[email protected] C:\Users\User\AppData\Roaming\npm\node_modules\supervizer
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
.1, [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], oauth-
[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected])

C:\Users\User\memeex>supervizer list

C:\Users\User\AppData\Roaming\npm\node_modules\supervizer\lib\main.js:21
        uid: process.getuid(),
                     ^
TypeError: Object # has no method 'getuid'
    at Object. (C:\Users\User\AppData\Roaming\npm\node_modules\supervizer\lib\main.js:21:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object. (C:\Users\User\AppData\Roaming\npm\node_modules\supervizer\bin\supervizer-client:10:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

Sample code

This project looks interesting and may be exactly what I need. I was wondering, do you have some sample code that shows how to use the REST API, especially how to start a node application with arguments, i.e. 'node app myargs' through the REST API. That would help me a lot. Also, I assume it's possible to start a node application from within another node application (without using the REST API) with your package, right? What is the javascript syntax to start an application, again with arguments? Thanks for any help you can provide!

Unable to connect to the server.

server.js (short version):

var host = process.argv[2] || '0.0.0.0';
var port = process.argv[3] || '5000';
server.listen(host, port, function() {
console.log('Server started');
});

prompt> supervizer start server.js -h 127.0.0.1 -p 8000

[ERROR]: (Network:700) - Unable to connect to the server.

prompt> supervizer start server.js

[ERROR]: (Network:700) - Unable to connect to the server.

Thanks,
Roy

Mem usage displays as KB instead of MB on OS X

Hello, thanks for supervizer! I noticed it read mem usage as KB instead of MB on OS X.. haven't tried on linux yet..

node 10.24 on OS X 10.9.1:
Predat0r:exostore J$ supervizer get exostore
[2013-12-21 16:27:02]: [INFO]: (exostore) App properties succesfully retrieved..

[host ]:
[port ]:
[created ]: 2013-12-21 16:08:46
[started ]: 2013-12-21 16:25:35

[uptime ]: 1m 27s

[stats.cpu ]: 0 %
[stats.memory ]: 63 KB

It should read 63 MB :-)

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.