1. make service file

sudo vim /etc/systemd/system/superset.service

fill this file with,

#superset.service

###########

[Unit]

Description=Visualization platform by Chrono

After=multi-user.target


[Service]

Type=simple

User=YOUR_USERNAME

ExecStart=/etc/init.d/superset


[Install]

WantedBy=default.target


2. make script

sudo vim /etc/init.d/superset 

fill this file with,

#!/bin/bash

source /your/virtualenv/path/bin/activate

/your/virtualenv/path/bin/superset runserver

make script to executable

sudo chmod +x /etc/init.d/superset 


3. update systemctl

sudo systemctl daemon-reload


4. start/stop/restart/status

sudo systemctl start superset

sudo systemctl stop superset

sudo systemctl restart superset

sudo systemctl status superset


블로그 이미지

시간을 거스르는자

,

If you are using mac,

Solution)

brew tap cartr/qt4
brew tap-pin cartr/qt4
brew install qt@4


'Android > OpenCV' 카테고리의 다른 글

OpenCV Manager app 필요 없이 OpenCV 사용하기  (1) 2014.07.03
블로그 이미지

시간을 거스르는자

,

1. Overview

2. Components

2-1. Log Creator: Game server instances -> Filebeat
2-2. Log Distributor: Logstash (logstash config example)
2-3. Log Warehouse: s3
2-4. Log Analyzer: python schedule makes job, python celery workers do the tasks. (loading data from S3 via Athena and aggregate and save it to MySQL) you can monitor celery workers using flower
2-5. Log Visualizer: ElasticSearch, Apache SuperSet

블로그 이미지

시간을 거스르는자

,

아파치 그룹 오픈소스: https://github.com/apache/incubator-superset

아주 기가막힌 오픈 소스가 있었다! 이름도 수퍼한 superset!!

데이터 베이스만 연결하면 드레그엔 드랍만으로 멋진 통계그래프를 볼수 있다!



블로그 이미지

시간을 거스르는자

,

1. sudo apt-get update

2. sudo apt install python-pip

3. pip install --upgrade pip

4. pip install --upgrade virtualenv

5. virtualenv -p python3 p3.5


블로그 이미지

시간을 거스르는자

,

  multiline.pattern: '^[[:space:]]'

  multiline.match: after

'서버 교양' 카테고리의 다른 글

How to make game server log system  (0) 2017.11.03
Mysql visualization tool(그래프 툴) Super set!  (0) 2017.11.03
logstash conf example  (0) 2017.10.13
python 3.5 flask gevent async requests test  (0) 2017.04.07
Logstash install  (0) 2017.03.17
블로그 이미지

시간을 거스르는자

,

logstash conf example

서버 교양 2017. 10. 13. 16:33

# this is for logstash configuration
input {
beats {
port => 5044
}
}

filter {
grok {
match => {
"message" => "%{TIMESTAMP_ISO8601:timestamp} \[%{DATA:log_level}\] %{DATA:url} (?<content>(.)*)"
}
}

if "_grokparsefailure" not in [tags] {
if [content] {
json {
source => "content"
}

if [dest] == "mongo" {
mutate {
add_field => {"logType" => "query"}
}
}
else {
mutate {
add_field => {"logType" => "log"}
}
}

}

mutate {
remove_field => [ "content", "message", "tags"]
gsub => ["timestamp", ",[0-9]+", ""]
}
}
else {
mutate {
add_field => {"logType" => "else"}
}
}
}

output {
if [logType] == "query" { # this is for query log
mongodb {
collection => "log"
database => "gamedb"
uri => "mongodb://"
codec => json
isodate => true
}
}
else if [logType] == "log" and [log_level] == "INFO" {
s3 {
access_key_id => ""
secret_access_key => ""
region => "us-east-1"
prefix => "%{+YYYY/MM/dd}/"
bucket => ""
size_file => 100000 # size: bytes, 100000 = 100kbytes
time_file => 5
codec => "json_lines"
}
}

elasticsearch {

    hosts => [search.~~.es.aws.com:80]

}
}


'서버 교양' 카테고리의 다른 글

Mysql visualization tool(그래프 툴) Super set!  (0) 2017.11.03
filebeat traceabck multiline config  (0) 2017.10.16
python 3.5 flask gevent async requests test  (0) 2017.04.07
Logstash install  (0) 2017.03.17
[펌] 인증 암호화와 해쉬  (0) 2016.10.29
블로그 이미지

시간을 거스르는자

,

monkey.patch_all(thread=False)

Remove "thread=False".

This makes thread hanging.


Refer to usage of pymongo + gevent on below site

http://api.mongodb.com/python/current/examples/gevent.html

https://stackoverflow.com/questions/7166998/pymongo-gevent-throw-me-a-banana-and-just-monkey-patch

They are telling,

"By default, PyMongo uses threads to discover and monitor your servers’ topology (see Health Monitoring). If you execute monkey.patch_all() when your application first begins, PyMongo automatically uses greenlets instead of threads."


'python' 카테고리의 다른 글

pytz localize vs normalize  (0) 2018.02.26
flask save session error  (0) 2017.12.05
gevent monkey patch all, code location  (0) 2017.09.14
flask with gevent monkey patch all  (0) 2017.07.26
flask gevent spawn use a lot of memory  (0) 2017.04.05
블로그 이미지

시간을 거스르는자

,

monkey patch all

1. 어느 위치에 써줘야할까?

문서에 보면 가능한 젤 위에 patch all코드를 쓰라고한다. 근데 상식적으로, import 모듈을 해놓고 패치를 해야 로드된걸 패치시키는게 아닐까? 라는 의문을 같게 된다.

대답은 맞다. 그렇지만 맨위에 쓰는게 맞다 이다.

왜냐면, monkey patch 를 지원하는 standard library들은 순서가 어찌되었건 몽키패치를 지원한다. 

from gevent.monkey import is_module_patched
from gevent import monkey;monkey.patch_all()
import socket
import threading
print(is_module_patched("socket"))
print(is_module_patched("threading"))

결과:

True
Ture

import socket
import threading
from gevent import monkey;monkey.patch_all()

print(is_module_patched("socket"))
print(is_module_patched("threading"))

결과:

True
True

그렇지만 몽키패치를 지원하지 않는 3rd library들은 위험할수도 있기 때문에 가급적 패치올을 맨위에 써서 영향이 안가도록 맨위에 쓰라는 것이다.


2. patch_all(thread=False) 

thread patch는 기본적으로 True다. thread가 몽키패치되게되면, threading을 쓰는 부분을 thread가 아니라 gevent에서 지원하는 Greenlet object로 바뀌게된다. 

일단 큰 차이는 context switching 시점이다.

thread는 내가 원하는 시점에 명시적으로 context switching을 하는게 아니라 os 스케줄에 따라서 context switching이 되어 쓸데없는 비용을 소비하게 될 확률이 높다.

그러나 greenlet object는 명시적 sleep이나 library의 io에 패치된 경우에 한해서 context switching이 된다.

참고로, windows 10에서는 maximum recursive error가 나오면서 patch_all 함수가 실패한다. 이때 thread=False 옵션을주면 잘 동작하게 된다. 아마 윈도우10에서는 thread패치를 완벽히 지원하지 않는것 같다. 


reference

1. https://stackoverflow.com/questions/39537004/gevent-monkey-patching-order

2. https://stackoverflow.com/questions/15556718/greenlet-vs-threads


'python' 카테고리의 다른 글

flask save session error  (0) 2017.12.05
python3 flask + pymongo + gevent, locust testing hangs  (0) 2017.09.26
flask with gevent monkey patch all  (0) 2017.07.26
flask gevent spawn use a lot of memory  (0) 2017.04.05
websocket with gunicorn  (0) 2017.03.03
블로그 이미지

시간을 거스르는자

,

Problem:

 - content length mismatched(ERR_CONTENT_LENGTH_MISMATCH)

 - response string truncated (cut off)


If you are using flask with gevent monkey patch all and you got such a problem above, 

than you should use gevent wsgi instead of flask app.run


For example..

from gevent import monkey

monkey.patch_all()

from flask import Flask

from gevent import wsgi


app = Flask(__name__)


@app.route('/')

def index():

  return 'Hello World'


server = wsgi.WSGIServer(('127.0.0.1', 5000), app)

server.serve_forever()

reason:

flask is not for aysnc future model, so if you want to use asynchronous for http or any socket use, than you should use gevent wsgi

'python' 카테고리의 다른 글

python3 flask + pymongo + gevent, locust testing hangs  (0) 2017.09.26
gevent monkey patch all, code location  (0) 2017.09.14
flask gevent spawn use a lot of memory  (0) 2017.04.05
websocket with gunicorn  (0) 2017.03.03
gunicorn vs uwsgi  (0) 2017.01.20
블로그 이미지

시간을 거스르는자

,