From 3042ddc81b886cd90c0aea498fa721f0df356abe Mon Sep 17 00:00:00 2001 From: amper43 Date: Tue, 9 Oct 2018 17:12:56 +0300 Subject: [PATCH] fix compose --- analytics/config.py | 2 ++ docker-compose.yml | 13 +++++-------- server/src/services/analytics_service.ts | 12 +++++++++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/analytics/config.py b/analytics/config.py index c4b2b2e..b867a3b 100644 --- a/analytics/config.py +++ b/analytics/config.py @@ -1,3 +1,5 @@ + + import os import json diff --git a/docker-compose.yml b/docker-compose.yml index 89d9906..d757602 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,22 +2,19 @@ version: '2' services: server: image: hastic-server - #build: server + build: server environment: HASTIC_API_KEY: "eyJrIjoiNzhiYjIyTGZDMjY4M3lnYTNwWHo3WFVaNnVDSm9qakkiLCJuIjoiaGFzIiwiaWQiOjF9" - ZMQ_HOST: analytics - volumes: - - data-volume:/var/www/data + ZMQ_CONNECTION_STRING: tcp://analytics:8002 ports: - 8000:8000 + volumes: + - data-volume:/var/www/data privileged: true analytics: image: hastic-analytics - #build: analytics - volumes: - - data-volume:/var/www/data - privileged: true + build: analytics volumes: data-volume: diff --git a/server/src/services/analytics_service.ts b/server/src/services/analytics_service.ts index 5592a20..6dda688 100644 --- a/server/src/services/analytics_service.ts +++ b/server/src/services/analytics_service.ts @@ -18,8 +18,12 @@ export class AnalyticsService { private _ipcPath: string = null; private _analyticsPinger: NodeJS.Timer = null; private _isClosed = false; + private _productionMode = false; + private _inDocker = false; constructor(private _onMessage: (message: AnalyticsMessage) => void) { + this._productionMode = process.env.NODE_ENV !== 'development'; + this._inDocker = process.env.INSIDE_DOCKER === 'true'; this._init(); } @@ -67,10 +71,12 @@ export class AnalyticsService { private async _init() { this._requester = zmq.socket('pair'); - let productionMode = process.env.NODE_ENV !== 'development' && process.env.INSIDE_DOCKER !== 'true'; this._zmqConnectionString = `tcp://${config.ZMQ_HOST}:${config.ZMQ_DEV_PORT}`; // debug mode - if(productionMode) { + + if(this._inDocker) { + this._zmqConnectionString = config.ZMQ_CONNECTION_STRING; + } else if(this._productionMode) { this._zmqConnectionString = config.ZMQ_CONNECTION_STRING; if(this._zmqConnectionString === null) { var createResult = await AnalyticsService.createIPCAddress(); @@ -84,7 +90,7 @@ export class AnalyticsService { this._requester.on("message", this._onAnalyticsMessage.bind(this)); console.log('Ok'); - if(productionMode) { + if(this._productionMode && !this._inDocker) { console.log('Creating analytics process...'); try { var cp = await AnalyticsService._runAnalyticsProcess(this._zmqConnectionString);