Просмотр исходного кода

Merge pull request #1480 from sharelatex/bg-allow-separate-websocket-url

allow setting separate wsUrl for websockets

GitOrigin-RevId: afd4f441397c6b4b402e342f1dec01c971847a0f
Brian Gough 7 лет назад
Родитель
Сommit
c51461da09

+ 1 - 0
services/web/app/views/layout.pug

@@ -68,6 +68,7 @@ html(
 		script.
 			window.sharelatex = {
 				siteUrl: '#{settings.siteUrl}',
+				wsUrl: '#{settings.wsUrl}',
 				jsPath:  '#{jsPath}',
 				sixpackDomain: '#{settings.sixpack.domain}'
 			};

+ 3 - 0
services/web/config/settings.defaults.coffee

@@ -188,6 +188,9 @@ module.exports = settings =
 	# that are sent out, generated links, etc.
 	siteUrl : siteUrl = process.env['PUBLIC_URL'] or 'http://localhost:3000'
 
+	# Optional separate location for websocket connections, if unset defaults to siteUrl.
+	wsUrl: process.env['WEBSOCKET_URL']
+
 	# cookie domain
 	# use full domain for cookies to only be accessible from that domain,
 	# replace subdomain with dot to have them accessible on all subdomains

+ 1 - 0
services/web/public/src/ide.js

@@ -185,6 +185,7 @@ define([
 
     ide.validFileRegex = '^[^*/]*$' // Don't allow * and /
 
+    ide.wsUrl = window.sharelatex.wsUrl || null // websocket url (if defined)
     ide.project_id = $scope.project_id = window.project_id
     ide.$scope = $scope
 

+ 2 - 1
services/web/public/src/ide/connection/ConnectionManager.js

@@ -33,6 +33,7 @@ define([], function() {
       constructor(ide, $scope) {
         this.ide = ide
         this.$scope = $scope
+        this.wsUrl = ide.wsUrl || null // websocket url (if defined)
         if (typeof io === 'undefined' || io === null) {
           console.error(
             'Socket.io javascript not loaded. Please check that the real-time service is running and accessible.'
@@ -94,7 +95,7 @@ define([], function() {
         })
 
         this.ide.socket = io.connect(
-          null,
+          this.wsUrl,
           {
             reconnect: false,
             'connect timeout': 30 * 1000,