Skip to content

Instantly share code, notes, and snippets.

@arcolife
Created August 8, 2017 09:46
Show Gist options
  • Save arcolife/8cceeca6f0a051a6312442a35fd5ad70 to your computer and use it in GitHub Desktop.
Save arcolife/8cceeca6f0a051a6312442a35fd5ad70 to your computer and use it in GitHub Desktop.
sarjitsu backend conf sample (standalone runs)
[ElasticSearch]
host = 0.0.0.0
port = 9200
[Settings]
index_prefix = sarjitsu
index_version = 1
bulk_action_count = 2000
number_of_shards = 5
number_of_replicas = 1
[Grafana]
dashboard_url = 0.0.0.0:3000
api_url = http://0.0.0.0:5000/
@arcolife
Copy link
Author

arcolife commented Aug 8, 2017

docker-compose up -d
then kill backend and keep the rest of 'em running:

         Name                       Command                State             Ports         
-------------------------------------------------------------------------------------------
sarjitsu_datasource_1    /docker-entrypoint.sh elastic    Up         0.0.0.0:9200->9200/tcp
sarjitsu_frontend_1      /docker-entrypoint.sh graf ...   Up         0.0.0.0:3000->3000/tcp
sarjitsu_metricstore_1   container-entrypoint run-p ...   Up         0.0.0.0:5432->5432/tcp
sarjitsu_middleware_1    /docker-entrypoint.sh api_ ...   Up         0.0.0.0:5000->5000/tcp
sarjitsu_nginx_1         /docker-entrypoint.sh prox ...   Up         0.0.0.0:8001->8001/tcp
sarjitsu_redis_1         docker-entrypoint.sh redis ...   Up         6379/tcp              
sarjitsu_web_1           /docker-entrypoint.sh backend    Exit 137                         

Then change config.py

diff --git a/lib/backend/src/config.py b/lib/backend/src/config.py
index 27b82df..8edf80f 100644
--- a/lib/backend/src/config.py
+++ b/lib/backend/src/config.py
@@ -2,8 +2,8 @@
 # -*- coding: utf-8 -*-
 
 # Statement for enabling the development environment
-DEBUG = False
-# DEBUG = True
+# DEBUG = False
+DEBUG = True
 
 import os
 BASE_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -11,7 +11,8 @@ BASE_DIR = os.path.abspath(os.path.dirname(__file__))
 LOG_FILENAME = 'sarjitsu_app.log'
 LOG_FILESIZE = 10000 # in Bytes
 
-CFG_PATH = "/opt/sarjitsu/conf/sar-index.cfg"
+# CFG_PATH = "/opt/sarjitsu/conf/sar-index.cfg"
+CFG_PATH = "../conf/sar-index.cfg"
 
 # Application threads. A common general assumption is
 # using 2 per available processor cores - to handle

Then copy conf/sar-index.cfg.example to conf/sar-index.cfg and paste contents from above gist snippet.

Then edit /etc/hosts and add 0.0.0.0 redis

Then go to src/ and run:

virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
./server.py

@arcolife
Copy link
Author

arcolife commented Aug 8, 2017

diff --git a/lib/backend/conf/sar-index.cfg.example b/lib/backend/conf/sar-index.cfg.example
index 9c961d3..97d1de5 100644
--- a/lib/backend/conf/sar-index.cfg.example
+++ b/lib/backend/conf/sar-index.cfg.example
@@ -1,5 +1,5 @@
 [ElasticSearch]
-host = 
+host = 0.0.0.0
 port = 9200
 
 [Settings]
@@ -10,5 +10,5 @@ number_of_shards = 5
 number_of_replicas = 1
 
 [Grafana]
-dashboard_url = 
-api_url = http://middleware:80/
+dashboard_url = 0.0.0.0:3000
+api_url = http://0.0.0.0:5000/
diff --git a/lib/backend/src/app/__init__.py b/lib/backend/src/app/__init__.py
index 3faaec5..b31129e 100644
--- a/lib/backend/src/app/__init__.py
+++ b/lib/backend/src/app/__init__.py
@@ -35,7 +35,7 @@ app.logger.addHandler(handler)
 # log.addHandler(handler)
 
 # app.cache = redis.StrictRedis(**app.config.get('REDIS_CONFIG'))
-app.cache = Redis(host='redis', port=6379)
+app.cache = Redis(host='172.18.0.2', port=6379)
 
 app.cache.set("saDir", SA_DIR)
 app.cache.set("uid_track", 1)
diff --git a/lib/backend/src/config.py b/lib/backend/src/config.py
index 27b82df..e75c594 100644
--- a/lib/backend/src/config.py
+++ b/lib/backend/src/config.py
@@ -2,8 +2,8 @@
 # -*- coding: utf-8 -*-
 
 # Statement for enabling the development environment
-DEBUG = False
-# DEBUG = True
+# DEBUG = False
+DEBUG = True
 
 import os
 BASE_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -11,7 +11,8 @@ BASE_DIR = os.path.abspath(os.path.dirname(__file__))
 LOG_FILENAME = 'sarjitsu_app.log'
 LOG_FILESIZE = 10000 # in Bytes
 
-CFG_PATH = "/opt/sarjitsu/conf/sar-index.cfg"
+# CFG_PATH = "/opt/sarjitsu/conf/sar-index.cfg"
+CFG_PATH = "/home/arco/workspace/sarjitsu/lib/backend/conf/sar-index.cfg.example"
 
 # Application threads. A common general assumption is
 # using 2 per available processor cores - to handle
diff --git a/lib/backend/src/upload_processor.py b/lib/backend/src/upload_processor.py
index 684b021..a0149a4 100644
--- a/lib/backend/src/upload_processor.py
+++ b/lib/backend/src/upload_processor.py
@@ -81,6 +81,7 @@ def begin(target, sessionID, form):
     for j in t_list:
         j.join()
 
+    import pdb; pdb.set_trace()
     _valid_results_found = False
     for filename in filename_list:
         nodename, meta, sadf = q[filename]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment