Browse Source

fix compose

pull/1/head
amper43 6 years ago
parent
commit
3042ddc81b
  1. 2
      analytics/config.py
  2. 13
      docker-compose.yml
  3. 12
      server/src/services/analytics_service.ts

2
analytics/config.py

@ -1,3 +1,5 @@
import os import os
import json import json

13
docker-compose.yml

@ -2,22 +2,19 @@ version: '2'
services: services:
server: server:
image: hastic-server image: hastic-server
#build: server build: server
environment: environment:
HASTIC_API_KEY: "eyJrIjoiNzhiYjIyTGZDMjY4M3lnYTNwWHo3WFVaNnVDSm9qakkiLCJuIjoiaGFzIiwiaWQiOjF9" HASTIC_API_KEY: "eyJrIjoiNzhiYjIyTGZDMjY4M3lnYTNwWHo3WFVaNnVDSm9qakkiLCJuIjoiaGFzIiwiaWQiOjF9"
ZMQ_HOST: analytics ZMQ_CONNECTION_STRING: tcp://analytics:8002
volumes:
- data-volume:/var/www/data
ports: ports:
- 8000:8000 - 8000:8000
volumes:
- data-volume:/var/www/data
privileged: true privileged: true
analytics: analytics:
image: hastic-analytics image: hastic-analytics
#build: analytics build: analytics
volumes:
- data-volume:/var/www/data
privileged: true
volumes: volumes:
data-volume: data-volume:

12
server/src/services/analytics_service.ts

@ -18,8 +18,12 @@ export class AnalyticsService {
private _ipcPath: string = null; private _ipcPath: string = null;
private _analyticsPinger: NodeJS.Timer = null; private _analyticsPinger: NodeJS.Timer = null;
private _isClosed = false; private _isClosed = false;
private _productionMode = false;
private _inDocker = false;
constructor(private _onMessage: (message: AnalyticsMessage) => void) { constructor(private _onMessage: (message: AnalyticsMessage) => void) {
this._productionMode = process.env.NODE_ENV !== 'development';
this._inDocker = process.env.INSIDE_DOCKER === 'true';
this._init(); this._init();
} }
@ -67,10 +71,12 @@ export class AnalyticsService {
private async _init() { private async _init() {
this._requester = zmq.socket('pair'); 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 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; this._zmqConnectionString = config.ZMQ_CONNECTION_STRING;
if(this._zmqConnectionString === null) { if(this._zmqConnectionString === null) {
var createResult = await AnalyticsService.createIPCAddress(); var createResult = await AnalyticsService.createIPCAddress();
@ -84,7 +90,7 @@ export class AnalyticsService {
this._requester.on("message", this._onAnalyticsMessage.bind(this)); this._requester.on("message", this._onAnalyticsMessage.bind(this));
console.log('Ok'); console.log('Ok');
if(productionMode) { if(this._productionMode && !this._inDocker) {
console.log('Creating analytics process...'); console.log('Creating analytics process...');
try { try {
var cp = await AnalyticsService._runAnalyticsProcess(this._zmqConnectionString); var cp = await AnalyticsService._runAnalyticsProcess(this._zmqConnectionString);

Loading…
Cancel
Save