mirror of
https://github.com/Unitech/pm2.git
synced 2025-12-08 20:35:53 +00:00
globalize interactor - update README.md - upgrade axm
This commit is contained in:
parent
09be1ad40d
commit
3c42ea4208
@ -83,7 +83,7 @@ If the above fails use:
|
||||
$ npm install git://github.com/Unitech/pm2#master -g
|
||||
```
|
||||
|
||||
We recommend Node.JS 0.11.13 for handling the cluster_mode (if you add the -i options to enable scaling and reload).
|
||||
We recommend Node.JS 0.11.14 for handling the cluster_mode (if you add the -i options to enable scaling and reload).
|
||||
|
||||
<a name="a2"/>
|
||||
## Usage
|
||||
@ -1058,9 +1058,9 @@ Also make sure you have all dependencies needed. For Ubuntu:
|
||||
$ sudo apt-get install build-essential
|
||||
# nvm is a Node.js version manager - https://github.com/creationix/nvm
|
||||
$ wget -qO- https://raw.github.com/creationix/nvm/master/install.sh | sh
|
||||
$ nvm install v0.11.10
|
||||
$ nvm use v0.11.10
|
||||
$ nvm alias default v0.11.10
|
||||
$ nvm install v0.11.14
|
||||
$ nvm use v0.11.14
|
||||
$ nvm alias default v0.11.14
|
||||
```
|
||||
|
||||
<a name="a27"/>
|
||||
|
||||
@ -18,7 +18,7 @@ $ npm install pm2 -g
|
||||
```
|
||||
|
||||
*npm is a builtin CLI when you install Node.js - [Installing Node.js with NVM](https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-an-ubuntu-14-04-server#how-to-install-using-nvm)*
|
||||
|
||||
We recommend Node.js 0.11.14.
|
||||
|
||||
## Start an application
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ var default_conf = {
|
||||
ERRORED_STATUS : 'errored',
|
||||
ONE_LAUNCH_STATUS : 'one-launch-status',
|
||||
|
||||
KEYMETRICS_ROOT_URL : 'https://root.keymetrics.io',
|
||||
KEYMETRICS_ROOT_URL : 'root.keymetrics.io',
|
||||
|
||||
REMOTE_PORT : 41624,
|
||||
REMOTE_REVERSE_PORT : 43554,
|
||||
|
||||
14
examples/tree.js
Normal file
14
examples/tree.js
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
var spawn = require('child_process').spawn,
|
||||
grep = spawn('top', [], { stdio: 'inherit' });
|
||||
|
||||
|
||||
var http = require('http');
|
||||
|
||||
|
||||
var normal = require('child_process').fork('examples/child.js', ['normal']);
|
||||
|
||||
http.createServer(function(req, res) {
|
||||
res.writeHead(200);
|
||||
res.end('hoy');
|
||||
}).listen(8010);
|
||||
@ -210,7 +210,7 @@ module.exports = function(God) {
|
||||
if (!pid) return cb({msg : 'no pid passed or null'});
|
||||
|
||||
try {
|
||||
process.kill(pid);
|
||||
process.kill(pid, 'SIGINT');
|
||||
} catch(e) {
|
||||
console.error('%s pid can not be killed', pid, e);
|
||||
return cb({type : 'kill', msg : pid + ' can not be killed'});
|
||||
|
||||
@ -94,13 +94,12 @@ var Daemon = {
|
||||
|
||||
HttpRequest.post({
|
||||
url : self.opts.ROOT_URL,
|
||||
port : 3000,
|
||||
port : self.opts.ROOT_PORT,
|
||||
data : {
|
||||
public_id : self.opts.PUBLIC_KEY,
|
||||
data : ciphered_data
|
||||
}
|
||||
}, function(err, km_data) {
|
||||
|
||||
if (err) return console.error(err);
|
||||
if (km_data.disabled == true) {
|
||||
console.error(chalk.cyan('[Keymetrics.io]') + ' Server DISABLED BY ADMINISTRATION contact support contact@keymetrics.io with reference to your public and secret keys)');
|
||||
@ -113,21 +112,20 @@ var Daemon = {
|
||||
|
||||
if ((Daemon.current_km_data.endpoints.push != km_data.endpoints.push) ||
|
||||
(Daemon.current_km_data.endpoints.reverse != km_data.endpoints.reverse)) {
|
||||
console.log('Url changed');
|
||||
console.log('[Interactor] Urls changed');
|
||||
PushInteractor.changeUrl(km_data.endpoints.push);
|
||||
ReverseInteractor.changeUrl(km_data.endpoints.reverse);
|
||||
Daemon.current_km_data = km_data;
|
||||
}
|
||||
|
||||
PushInteractor.changeUrl(km_data.endpoints.push);
|
||||
ReverseInteractor.changeUrl(km_data.endpoints.reverse);
|
||||
|
||||
Daemon.current_km_data = km_data;
|
||||
return false;
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
// Refresh metadata every 10 minutes
|
||||
setInterval(function() {
|
||||
refreshMetadata();
|
||||
}, 5000);
|
||||
}, 60000 * 10);
|
||||
},
|
||||
validateData : function() {
|
||||
var opts = {};
|
||||
@ -152,7 +150,7 @@ var Daemon = {
|
||||
}
|
||||
return opts;
|
||||
},
|
||||
welcome : function(url, cb) {
|
||||
welcome : function(cb) {
|
||||
var self = this;
|
||||
var ciphered_data = Daemon.formatMetada();
|
||||
|
||||
@ -164,19 +162,9 @@ var Daemon = {
|
||||
return process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
var port = 443;
|
||||
|
||||
if (cst.DEBUG) {
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
port = 3400;
|
||||
else
|
||||
port = 3000;
|
||||
}
|
||||
|
||||
HttpRequest.post({
|
||||
url : url,
|
||||
port : port,
|
||||
url : self.opts.ROOT_URL,
|
||||
port : self.opts.ROOT_PORT,
|
||||
data : {
|
||||
public_id : this.opts.PUBLIC_KEY,
|
||||
data : ciphered_data
|
||||
@ -212,21 +200,25 @@ var Daemon = {
|
||||
self.opts.ipm2 = null;
|
||||
self.current_km_data = null;
|
||||
|
||||
// Expose Interactor methods
|
||||
self._rpc = self.activateRPC();
|
||||
|
||||
// WatchDog.start({
|
||||
// conf : self.opts
|
||||
// });
|
||||
|
||||
var root_url = cst.KEYMETRICS_ROOT_URL;
|
||||
if (cst.DEBUG) {
|
||||
self.opts.ROOT_URL = '127.0.0.1';
|
||||
if (process.env.NODE_ENV == 'test')
|
||||
self.opts.ROOT_PORT = 3400;
|
||||
else
|
||||
self.opts.ROOT_PORT = 3000;
|
||||
}
|
||||
else {
|
||||
self.opts.ROOT_URL = cst.KEYMETRICS_ROOT_URL;
|
||||
self.opts.ROOT_PORT = 443;
|
||||
}
|
||||
|
||||
if (cst.DEBUG)
|
||||
root_url = 'http://127.0.0.1',
|
||||
|
||||
self.opts.ROOT_URL = root_url;
|
||||
|
||||
Daemon.welcome(root_url, function(err, km_data) {
|
||||
Daemon.welcome(function(err, km_data) {
|
||||
if (err) {
|
||||
process.send({
|
||||
error : true,
|
||||
@ -249,7 +241,7 @@ var Daemon = {
|
||||
self.opts.ipm2 = self.connectToPM2();
|
||||
|
||||
PushInteractor.start({
|
||||
url : km_data.endpoints.push,
|
||||
url : km_data.endpoints.push,
|
||||
conf : self.opts
|
||||
});
|
||||
|
||||
@ -259,7 +251,7 @@ var Daemon = {
|
||||
conf : self.opts
|
||||
});
|
||||
}
|
||||
//Daemon.refreshWorker();
|
||||
Daemon.refreshWorker();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
|
||||
var http = require('http');
|
||||
var https = require('https');
|
||||
var urlParser = require('url');
|
||||
var debug = require('debug')('interface:http');
|
||||
|
||||
var HttpRequest = module.exports = {};
|
||||
@ -10,11 +9,10 @@ HttpRequest.post = function(opts, cb) {
|
||||
if (!(opts.port && opts.data && opts.url))
|
||||
return cb({msg : 'missing parameters', port : opts.port, data : opts.data, url : opts.url});
|
||||
|
||||
var uri = urlParser.parse(opts.url);
|
||||
var port = 0;
|
||||
|
||||
var options = {
|
||||
hostname : uri.host,
|
||||
hostname : opts.url,
|
||||
path : '/api/node/verifyPM2',
|
||||
method : 'POST',
|
||||
port : opts.port,
|
||||
@ -27,7 +25,7 @@ HttpRequest.post = function(opts, cb) {
|
||||
var client = (opts.port == 443) ? https : http;
|
||||
|
||||
var timeout = setTimeout(function() {
|
||||
cb({msg : 'Connection timed out to ' + uri, success:false});
|
||||
cb({msg : 'Connection timed out ' + opts.url, success:false});
|
||||
}, 3000);
|
||||
|
||||
var req = client.request(options, function(res){
|
||||
|
||||
@ -14,6 +14,10 @@ var Cipher = require('./Cipher.js');
|
||||
var Utility = require('../Utility.js');
|
||||
|
||||
var PushInteractor = module.exports = {
|
||||
changeUrl : function(url) {
|
||||
console.log('[PUSH] Changing URL to %s', url);
|
||||
this.udpSocket = punt.connect(Url.parse(url).host);
|
||||
},
|
||||
start : function(p) {
|
||||
if (!p.url) throw new Error('missing endpoint url');
|
||||
if (!p.conf || !p.conf.ipm2) throw new Error('ipm2 is not initialized');
|
||||
@ -75,9 +79,6 @@ var PushInteractor = module.exports = {
|
||||
*/
|
||||
this.processEvents();
|
||||
},
|
||||
// changeUrl : function(url) {
|
||||
// this.udpSocket = punt.connect(Url.parse(url).host);
|
||||
// },
|
||||
/**
|
||||
* Send bufferized data at regular interval
|
||||
*/
|
||||
@ -162,8 +163,6 @@ var PushInteractor = module.exports = {
|
||||
this.preparePacket(function() {
|
||||
var data = {};
|
||||
|
||||
debug(self._packet);
|
||||
|
||||
if (process.env.NODE_ENV && process.env.NODE_ENV == 'test') {
|
||||
data = {
|
||||
public_key : PushInteractor.conf.PUBLIC_KEY,
|
||||
|
||||
@ -5,11 +5,13 @@ var Url = require('url');
|
||||
var Cipher = require('./Cipher.js');
|
||||
|
||||
var ReverseInteract = module.exports = {
|
||||
// changeUrl : function(url) {
|
||||
// if (!this.connected) return;
|
||||
// this.network = Url.parse(url);
|
||||
// // TODO
|
||||
// },
|
||||
changeUrl : function(url) {
|
||||
if (!this.connected) return;
|
||||
console.log('[REV] Changing URL to %s', url);
|
||||
this.network = Url.parse(url);
|
||||
this.socket.reconnect();
|
||||
// TODO
|
||||
},
|
||||
start : function(p) {
|
||||
if (!p.url) throw new Error('url not declared');
|
||||
if (!p.conf || !p.conf.ipm2) throw new Error('ipm2 ĩs not initialized');
|
||||
|
||||
@ -133,7 +133,7 @@
|
||||
"nssocket" : "0.5.1",
|
||||
"pidusage" : "0.1.0",
|
||||
|
||||
"axm" : "0.2.12",
|
||||
"axm" : "0.2.13",
|
||||
"pm2-axon" : "2.0.5",
|
||||
"pm2-axon-rpc" : "0.3.5",
|
||||
"pm2-deploy" : "~0.1.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user