diff --git a/README.md b/README.md index 9a7ac18c..525aa8ac 100644 --- a/README.md +++ b/README.md @@ -587,6 +587,15 @@ Setting this parameter to `true` will force Cronicle's Web UI to connect to the This property only takes effect if [web_direct_connect](#web_direct_connect) is also set to `true`. +### custom_live_log_socket_url +This is an fancy configuration to provide a url for web socket which live log needs to connect. +Notice this is useful for single-master system behind an LB. +Socket URL should be like this, e.g. +```js +"custom_live_log_socket_url": "http://127.0.0.1:8888" +``` +Feel free to change the ip and the port. + ### socket_io_transports This is an advanced configuration property that you will probably never need to worry about. This allows you to customize the [socket.io transports](https://socket.io/docs/client-api/) used to connect to the server for real-time updates. By default, this property is set internally to an array containing the `websocket` transport only, e.g. diff --git a/htdocs/css/style.css b/htdocs/css/style.css index 4c6945da..372e874e 100644 --- a/htdocs/css/style.css +++ b/htdocs/css/style.css @@ -9,7 +9,7 @@ div.container { position: relative; width: 40px; height: 40px; - background: url(/images/clock-bkgnd.png) no-repeat center center; + background: url(../images/clock-bkgnd.png) no-repeat center center; background-size: 36px 36px; } @@ -35,15 +35,15 @@ div.container { } #d_header_clock_hour { - background-image: url(/images/clock-hour.png); + background-image: url(../images/clock-hour.png); } #d_header_clock_minute { - background-image: url(/images/clock-minute.png); + background-image: url(../images/clock-minute.png); } #d_header_clock_second { - background-image: url(/images/clock-second.png); + background-image: url(../images/clock-second.png); } #d_tab_time { diff --git a/htdocs/index-dev.html b/htdocs/index-dev.html index 1b5d7898..2c3bae69 100755 --- a/htdocs/index-dev.html +++ b/htdocs/index-dev.html @@ -6,7 +6,7 @@ Loading... - + @@ -112,8 +112,8 @@ - - + + \ No newline at end of file diff --git a/htdocs/js/app.js b/htdocs/js/app.js index ff2f3e08..ac8e6944 100755 --- a/htdocs/js/app.js +++ b/htdocs/js/app.js @@ -22,7 +22,7 @@ app.extend({ // receive config from server if (resp.code) { app.showProgress( 1.0, "Waiting for master server..." ); - setTimeout( function() { load_script( '/api/app/config?callback=app.receiveConfig' ); }, 1000 ); + setTimeout( function() { load_script( 'api/app/config?callback=app.receiveConfig' ); }, 1000 ); return; } delete resp.code; @@ -79,7 +79,7 @@ app.extend({ for (var idx = 0, len = this.preload_images.length; idx < len; idx++) { var filename = '' + this.preload_images[idx]; var img = new Image(); - img.src = '/images/'+filename; + img.src = 'images/'+filename; } // populate prefs for first time user @@ -230,7 +230,7 @@ app.extend({ doExternalLogin: function() { // login using external user management system // Force API to hit current page hostname vs. master server, so login redirect URL reflects it - app.api.post( '/api/user/external_login', { cookie: document.cookie }, function(resp) { + app.api.post( 'api/user/external_login', { cookie: document.cookie }, function(resp) { if (resp.user) { Debug.trace("User Session Resume: " + resp.username + ": " + resp.session_id); app.hideProgress(); @@ -275,8 +275,8 @@ app.extend({ this.socket.removeAllListeners(); if (this.socket.connected) this.socket.disconnect(); this.socket = null; - } - + } + const path = config.subdir + "/socket.io"; var socket = this.socket = io( url, { // forceNew: true, transports: config.socket_io_transports || ['websocket'], @@ -284,7 +284,8 @@ app.extend({ reconnectionDelay: 1000, reconnectionDelayMax: 2000, reconnectionAttempts: 9999, - timeout: 3000 + timeout: 3000, + path:path, } ); socket.on('connect', function() { @@ -486,14 +487,14 @@ app.extend({ this.masterHostname = hostname; if (config.web_direct_connect) { - this.base_api_url = this.proto + this.masterHostname + ':' + this.port + config.base_api_uri; + this.base_api_url = this.proto + this.masterHostname + ':' + this.port + config.subdir + config.base_api_uri; if (!config.web_socket_use_hostnames && this.servers && this.servers[this.masterHostname] && this.servers[this.masterHostname].ip) { // use ip instead of hostname if available - this.base_api_url = this.proto + this.servers[this.masterHostname].ip + ':' + this.port + config.base_api_uri; + this.base_api_url = this.proto + this.servers[this.masterHostname].ip + ':' + this.port + config.subdir + config.base_api_uri; } } else { - this.base_api_url = this.proto + location.host + config.base_api_uri; + this.base_api_url = this.proto + location.host + config.subdir + config.base_api_uri; } Debug.trace("API calls now going to: " + this.base_api_url); diff --git a/htdocs/js/pages/JobDetails.class.js b/htdocs/js/pages/JobDetails.class.js index 5a0e3d3d..7e154723 100644 --- a/htdocs/js/pages/JobDetails.class.js +++ b/htdocs/js/pages/JobDetails.class.js @@ -1057,7 +1057,7 @@ Class.subclass( Page.Base, "Page.JobDetails", { $('#d_live_job_log').append( '
Log Watcher: Connecting to server: ' + url + '...
' ); - + const path = config.subdir + "/socket.io"; this.socket = io( url, { forceNew: true, transports: config.socket_io_transports || ['websocket'], @@ -1065,7 +1065,8 @@ Class.subclass( Page.Base, "Page.JobDetails", { reconnectionDelay: 1000, reconnectionDelayMax: 5000, reconnectionAttempts: 9999, - timeout: 5000 + timeout: 5000, + path:path } ); this.socket.on('connect', function() { diff --git a/lib/api/config.js b/lib/api/config.js index f8f34a3f..31c801b2 100644 --- a/lib/api/config.js +++ b/lib/api/config.js @@ -23,17 +23,25 @@ module.exports = Class.create({ return callback({ code: 'master', description: "No master server found" }); } + var subdir = this.server.config.get("subdir"); + if (subdir && subdir.match(/^\/?([A-z0-9-_+]+\/?)+$/g)) { + subdir = "/" + subdir.replace(/^\/|\/$/g, ''); + } else { + subdir = ""; + } var resp = { code: 0, version: this.server.__version, config: Tools.mergeHashes( this.server.config.get('client'), { debug: this.server.debug ? 1 : 0, job_memory_max: this.server.config.get('job_memory_max'), + subdir: subdir, base_api_uri: this.api.config.get('base_uri'), default_privileges: this.usermgr.config.get('default_privileges'), free_accounts: this.usermgr.config.get('free_accounts'), external_users: this.usermgr.config.get('external_user_api') ? 1 : 0, external_user_api: this.usermgr.config.get('external_user_api') || '', + custom_live_log_socket_url: this.server.config.get('custom_live_log_socket_url'), web_socket_use_hostnames: this.server.config.get('web_socket_use_hostnames') || 0, web_direct_connect: this.server.config.get('web_direct_connect') || 0, socket_io_transports: this.server.config.get('socket_io_transports') || 0 diff --git a/lib/test.js b/lib/test.js index 7e9ede29..58bd554d 100644 --- a/lib/test.js +++ b/lib/test.js @@ -105,7 +105,8 @@ module.exports = { // prepare to make api calls request = cronicle.request; - api_url = server.config.get('base_app_url') + server.API.config.get('base_uri'); + api_url = server.config.get('base_app_url') + + server.config.get('subdir') + server.API.config.get('base_uri'); // cancel auto ticks, so we can send our own later clearTimeout( server.tickTimer ); diff --git a/sample_conf/config.json b/sample_conf/config.json index 09312f69..e0fb2ff1 100644 --- a/sample_conf/config.json +++ b/sample_conf/config.json @@ -1,5 +1,6 @@ { "base_app_url": "http://localhost:3012", + "subdir": "", "email_from": "admin@localhost", "smtp_hostname": "localhost", "smtp_port": 25,