fix: CORF
This commit is contained in:
parent
2f9e30999a
commit
c3d5d53242
|
|
@ -30,7 +30,7 @@ function Monitor(options) {
|
|||
this._init(options);
|
||||
};
|
||||
|
||||
Monitor.ACCEPT_KEYS = ['pm2', 'refresh', 'daemonize', 'max_restarts', 'port', 'log', 'agent', 'remotes'];
|
||||
Monitor.ACCEPT_KEYS = ['pm2', 'refresh', 'daemonize', 'max_restarts', 'port', 'log', 'agent', 'remotes', 'origins'];
|
||||
Monitor.DEF_CONF_FILE = 'pm2-gui.ini';
|
||||
Monitor.PM2_DAEMON_PROPS = ['DAEMON_RPC_PORT', 'DAEMON_PUB_PORT'];
|
||||
|
||||
|
|
|
|||
11
pm2-gui.ini
11
pm2-gui.ini
|
|
@ -32,6 +32,11 @@ date = false
|
|||
; Log level, one of debug, log, info, warn, error.
|
||||
;
|
||||
level = debug
|
||||
;
|
||||
; Socket.io origins check, e.g.:
|
||||
; origins = 'example.com:* http://example.com:* http://www.example.com:8088'
|
||||
; By default:
|
||||
; origins = *:*
|
||||
|
||||
[agent]
|
||||
;
|
||||
|
|
@ -41,7 +46,7 @@ authorization = AuTh
|
|||
;
|
||||
; A value indicates whether agent offline or not.
|
||||
;
|
||||
; offline = true
|
||||
offline = true
|
||||
[remotes]
|
||||
;
|
||||
; the dashboard and web server will use this section to connect remoting socket server
|
||||
|
|
@ -51,3 +56,7 @@ authorization = AuTh
|
|||
; pm2@172 = 192.168.1.172:9001
|
||||
; pm2@173 = 192.168.1.173:9000
|
||||
;
|
||||
pm2@129 = AuTh@192.168.100.129:9009
|
||||
pm2@130 = AuTh@192.168.100.130:8088
|
||||
pm2@131 = AuTh@192.168.100.131:8088
|
||||
pm2@138 = AuTh@192.168.100.138:8088
|
||||
12
pm2-gui.js
12
pm2-gui.js
|
|
@ -60,7 +60,9 @@ function startWebServer(confFile) {
|
|||
port: options.port
|
||||
});
|
||||
|
||||
monitor.sockio = socketIO(server);
|
||||
monitor.sockio = socketIO(server, {
|
||||
origins: options.origins || '*:*'
|
||||
});
|
||||
monitor.run();
|
||||
console.info('Web server is listening on 127.0.0.1:' + options.port);
|
||||
}
|
||||
|
|
@ -78,7 +80,9 @@ function startAgent(confFile) {
|
|||
}
|
||||
options.port = options.port || 8088;
|
||||
var sockio = socketIO();
|
||||
sockio.listen(options.port);
|
||||
sockio.listen(options.port, {
|
||||
origins: options.origins || '*:*'
|
||||
});
|
||||
monitor.sockio = sockio;
|
||||
monitor.run();
|
||||
console.info('Socket.io server is listening on 0.0.0.0:' + options.port);
|
||||
|
|
@ -214,7 +218,9 @@ function _connectToDashboard(monitor, options, connection) {
|
|||
}
|
||||
console.warn('Agent is offline, try to start it.');
|
||||
var sockio = socketIO();
|
||||
sockio.listen(connection.port);
|
||||
sockio.listen(connection.port, {
|
||||
origins: options.origins || '*:*'
|
||||
});
|
||||
monitor.sockio = sockio;
|
||||
monitor.run();
|
||||
layout(connection).render(monitor);
|
||||
|
|
|
|||
|
|
@ -108,8 +108,11 @@ function setFPEnable(enable, unscrollable) {
|
|||
* Connect to socket server.
|
||||
*/
|
||||
function connectSocketServer(ns) {
|
||||
var uri = GUI.connection.value,
|
||||
index = uri.indexOf('?'),
|
||||
var uri = GUI.connection.value;
|
||||
if(GUI.connection.short == 'localhost'){
|
||||
uri = uri.replace(/(127\.0.0\.1|localhost|0\.0\.0\.0)/, location.hostname);
|
||||
}
|
||||
var index = uri.indexOf('?'),
|
||||
query = '';
|
||||
if (index > 0) {
|
||||
query = uri.slice(index);
|
||||
|
|
@ -433,7 +436,7 @@ function addChooser(options) {
|
|||
if (conn == '-') {
|
||||
html += '<li role = "separator" class="divider"></li>';
|
||||
} else {
|
||||
html += '<li ' + (GUI.connection.value == conn.value ? 'class="active"' : '') + '><a href="javascript:void(0);" data-value="' + conn.value + '">' + conn.name + '</a></li>';
|
||||
html += '<li ' + (GUI.connection.value == conn.value ? 'class="active"' : '') + '><a href="javascript:void(0);" data-value="' + conn.value + '" data-short="' + conn.short + '">' + conn.name + '</a></li>';
|
||||
}
|
||||
});
|
||||
html += '</ul>';
|
||||
|
|
@ -444,7 +447,8 @@ function addChooser(options) {
|
|||
if (val && val != GUI.connection.value) {
|
||||
GUI.connection = {
|
||||
name: ele.text(),
|
||||
value: val
|
||||
value: val,
|
||||
short: ele.data('short')
|
||||
};
|
||||
chooser.find('li.active').removeClass('active');
|
||||
ele.parent().addClass('active');
|
||||
|
|
|
|||
Loading…
Reference in New Issue