remove elasticsearch and use db based event logging
parent
6d9abe3a6d
commit
b1ce459be6
@ -1,9 +0,0 @@
|
||||
FROM ubuntu:19.10
|
||||
WORKDIR /srv
|
||||
COPY requirements.txt .
|
||||
RUN apt-get update && apt-get install python3-pip -y
|
||||
RUN python3 -m pip install -r requirements.txt
|
||||
COPY wowstash wowstash/
|
||||
COPY bin/ bin/
|
||||
EXPOSE 4001
|
||||
CMD ["/srv/bin/prod-container"]
|
@ -1,22 +0,0 @@
|
||||
services:
|
||||
kibana:
|
||||
image: docker.elastic.co/kibana/kibana:7.1.0
|
||||
ports:
|
||||
- 5601:5601
|
||||
environment:
|
||||
ELASTICSEARCH_HOSTS: http://elasticsearch:9200
|
||||
elasticsearch:
|
||||
image: docker.elastic.co/elasticsearch/elasticsearch:7.1.0
|
||||
environment:
|
||||
- discovery.type=single-node
|
||||
- node.name=elasticsearch
|
||||
- cluster.name=es-docker-cluster
|
||||
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
volumes:
|
||||
- ./data/elasticsearch:/usr/share/elasticsearch/data
|
||||
ports:
|
||||
- 9200:9200
|
@ -1,22 +0,0 @@
|
||||
from datetime import datetime
|
||||
from elasticsearch import Elasticsearch
|
||||
from wowstash import config
|
||||
|
||||
|
||||
def send_es(data):
|
||||
if getattr(config, 'ELASTICSEARCH_ENABLED', False):
|
||||
try:
|
||||
es = Elasticsearch(
|
||||
[getattr(config, 'ELASTICSEARCH_HOST', 'localhost')]
|
||||
)
|
||||
now = datetime.utcnow()
|
||||
index_ts = now.strftime('%Y%m%d')
|
||||
data['datetime'] = now
|
||||
es.index(
|
||||
index="{}-{}".format(
|
||||
getattr(config, 'ELASTICSEARCH_INDEX_NAME', 'wowstash'),
|
||||
index_ts
|
||||
), body=data)
|
||||
except Exception as e:
|
||||
print('Could not capture event in Elasticsearch: ', e)
|
||||
pass # I don't really care if this logs...
|
@ -0,0 +1,12 @@
|
||||
from wowstash.models import Event
|
||||
from wowstash.factory import db
|
||||
|
||||
|
||||
def capture_event(user_id, event_type):
|
||||
event = Event(
|
||||
user=user_id,
|
||||
type=event_type
|
||||
)
|
||||
db.session.add(event)
|
||||
db.session.commit()
|
||||
return
|
Loading…
Reference in New Issue