From f9cf8ba7e8ae8f54b2ba38a3d8fbe5283a84bd5c Mon Sep 17 00:00:00 2001 From: Martin Guether Date: Fri, 7 Apr 2017 11:55:07 +0200 Subject: [PATCH] update ports and variables for docker compose bootstrap --- README.md | 2 +- app.js | 4 ++-- config/default.json | 4 ++-- helpers/phantom.js | 47 ++++++++++++++++++++++++------------------- helpers/redis.js | 2 +- helpers/uploader.js | 9 +++++++++ helpers/websockets.js | 6 +++--- models/team.js | 2 +- views/spacedeck.html | 8 ++++---- 9 files changed, 49 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 0f42318..08ce9f9 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ To rebuild the frontend CSS styles (you need to do this at least once): export NODE_ENV=development npm start -#experimental docker support +# experimental docker support We have a docker base image at https://github.com/spacedeck/docker-baseimage that includes all required binaries. Based on this image we can use Docker-Compose to bootstrap a Spacedeck including data storages. diff --git a/app.js b/app.js index 24b4fb5..be1ffb9 100644 --- a/app.js +++ b/app.js @@ -121,11 +121,11 @@ if (app.get('env') == 'development') { module.exports = app; // CONNECT TO DATABASE -const mongoHost = process.env.MONGO_PORT_27017_TCP_ADDR || 'localhost'; +const mongoHost = process.env.MONGO_PORT_27017_TCP_ADDR || 'db'; mongoose.connect('mongodb://' + mongoHost + '/spacedeck'); // START WEBSERVER -const port = 9000; +const port = 9666; const server = http.Server(app).listen(port, () => { diff --git a/config/default.json b/config/default.json index 445fa23..51317c2 100644 --- a/config/default.json +++ b/config/default.json @@ -1,7 +1,7 @@ { - "endpoint": "http://localhost:9000", + "endpoint": "http://localhost:9666", "storage_bucket": "my_spacedeck_s3_bucket", - "storage_cdn": "xyz.cloudfront.net", + "storage_cdn": "http://localhost:9666", "google_access" : "", "google_secret" : "", "admin_pass": "very_secret_admin_password", diff --git a/helpers/phantom.js b/helpers/phantom.js index c195a52..2d6fa1d 100644 --- a/helpers/phantom.js +++ b/helpers/phantom.js @@ -32,31 +32,36 @@ module.exports = { }; phantom.create({ path: require('phantomjs-prebuilt').path }, function (err, browser) { - return browser.createPage(function (err, page) { - console.log("page created, opening ",space_url); + if(err){ + console.err(err); + }else{ + return browser.createPage(function (err, page) { + console.log("page created, opening ",space_url); - if (type=="pdf") { - var psz = { - width: space.advanced.width+"px", - height: space.advanced.height+"px" - }; - page.set('paperSize', psz); - } + if (type=="pdf") { + var psz = { + width: space.advanced.width+"px", + height: space.advanced.height+"px" + }; + page.set('paperSize', psz); + } - page.set('settings.resourceTimeout',timeout); - page.set('settings.javascriptEnabled',false); + page.set('settings.resourceTimeout',timeout); + page.set('settings.javascriptEnabled',false); - return page.open(space_url, function (err,status) { - page.render(export_path, function() { - on_success_called = true; - if (on_success) { - on_success(export_path); - } - page.close(); - browser.exit(); + return page.open(space_url, function (err,status) { + page.render(export_path, function() { + on_success_called = true; + if (on_success) { + on_success(export_path); + } + page.close(); + browser.exit(); + }); }); - }); - }); + }); + } + }, { onExit: on_exit }); diff --git a/helpers/redis.js b/helpers/redis.js index 90b440a..0198d38 100644 --- a/helpers/redis.js +++ b/helpers/redis.js @@ -5,7 +5,7 @@ const websockets = require('./websockets'); module.exports = { connectRedis(){ - const redisHost = process.env.REDIS_PORT_6379_TCP_ADDR || 'localhost'; + const redisHost = process.env.REDIS_PORT_6379_TCP_ADDR || 'sync'; this.connection = new RedisConnection(6379, redisHost); }, sendMessage(action, model, attributes, channelId) { diff --git a/helpers/uploader.js b/helpers/uploader.js index c314062..95c2b32 100644 --- a/helpers/uploader.js +++ b/helpers/uploader.js @@ -6,6 +6,15 @@ AWS.config.region = 'eu-central-1'; var fs = require('fs'); var config = require('config'); +var cdn = config.get("storage_cdn") +var storage_endpoint = 'http://storage:9000'; +const bucketName = "sdeck-fresh-development"; +const ep = new AWS.Endpoint(storage_endpoint); +const s3 = new AWS.S3({ + endpoint: ep +}); + + module.exports = { removeFile: (path, callback) => { const s3 = new AWS.S3({ diff --git a/helpers/websockets.js b/helpers/websockets.js index 26fcd1c..48a8222 100644 --- a/helpers/websockets.js +++ b/helpers/websockets.js @@ -3,7 +3,7 @@ require('../models/schema'); const WebSocketServer = require('ws').Server; -const Redis = require('ioredis'); +const RedisConnection = require('ioredis'); const async = require('async'); const _ = require("underscore"); const mongoose = require("mongoose"); @@ -12,7 +12,7 @@ const crypto = require('crypto'); module.exports = { startWebsockets: function(server){ this.setupSubscription(); - this.state = new Redis(6379, process.env.REDIS_PORT_6379_TCP_ADDR || 'localhost'); + this.state = new RedisConnection(6379, process.env.REDIS_PORT_6379_TCP_ADDR || 'sync'); if(!this.current_websockets){ this.current_websockets = []; @@ -117,7 +117,7 @@ module.exports = { }, setupSubscription: function() { - this.cursorSubscriber = new Redis(6379, process.env.REDIS_PORT_6379_TCP_ADDR || 'localhost'); + this.cursorSubscriber = new RedisConnection(6379, process.env.REDIS_PORT_6379_TCP_ADDR || 'sync'); this.cursorSubscriber.subscribe(['cursors', 'users', 'updates'], function (err, count) { console.log("[redis] websockets to " + count + " topics." ); }); diff --git a/models/team.js b/models/team.js index a1f3cc7..b35942c 100644 --- a/models/team.js +++ b/models/team.js @@ -45,7 +45,7 @@ module.exports.teamSchema.index({ module.exports.teamSchema.statics.getTeamForHost = (host, cb) => { - if (host != "127.0.0.1:9000") { //phantomjs check + if (host != "127.0.0.1:9666") { //phantomjs check let subDomainParts = host.split('.'); if (subDomainParts.length > 2) { diff --git a/views/spacedeck.html b/views/spacedeck.html index 54144dd..bc93fbd 100644 --- a/views/spacedeck.html +++ b/views/spacedeck.html @@ -23,10 +23,10 @@ {% if process.env.NODE_ENV != "production" %} var ENV = { name: 'development', - webHost: "localhost:9000", - webEndpoint:"http://localhost:9000", - apiEndpoint: "http://localhost:9000", - websocketsEndpoint: "ws://localhost:9000" + webHost: "localhost:9666", + webEndpoint:"http://localhost:9666", + apiEndpoint: "http://localhost:9666", + websocketsEndpoint: "ws://localhost:9666" }; {% endif %}