Last active
August 21, 2017 17:53
-
-
Save c0psrul3/698077569cb83535134a0f5b3e859bf2 to your computer and use it in GitHub Desktop.
Graphite-api config and uWSGI start (for use with Grafana)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[uwsgi] | |
processes = 2 | |
http-socket = localhost:8001 | |
uid = 165 | |
gid = 165 | |
module = graphite_api.app:app | |
daemonize2 = /var/log/uwsgi-graphiteapi.log | |
env = GRAPHITE_API_CONFIG=/usr/local/etc/graphite-api.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# On FreeBSD, this file is placed in /usr/local/etc/graphite-api.yaml | |
--- | |
## [https://graphite-api.readthedocs.io/en/latest/configuration.html#default-values] | |
search_index: /opt/graphite/index | |
finders: | |
- graphite_api.finders.whisper.WhisperFinder | |
functions: | |
- graphite_api.functions.SeriesFunctions | |
- graphite_api.functions.PieFunctions | |
whisper: | |
directories: | |
- /opt/graphite/carbon/whisper | |
time_zone: UTC |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## reference links: | |
## - [https://github.com/brutasse/graphite-api] | |
## - [https://graphite-api.readthedocs.io/en/latest/deployment.html] | |
## - [http://graphite.readthedocs.io/en/latest/config-local-settings.html] | |
## - [http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html#basic-uwsgi-installation-and-configuration] | |
GRAPHITE_API_CONFIG="/usr/local/etc/graphite-api.yaml" | |
GRAPHITE_API_WSGI="/usr/local/etc/graphite-api.wsgi" | |
GAPI_PORT=8001 | |
UWSGI_DAEMONIZE="--daemonize" | |
check_graphiteapi_yaml() { | |
if [[ ! -f ${GRAPHITE_API_CONFIG} ]] ; then | |
cat <<CONFIG > ${GRAPHITE_API_CONFIG} | |
--- | |
## [https://graphite-api.readthedocs.io/en/latest/configuration.html#default-values] | |
search_index: /opt/graphite/index | |
finders: | |
- graphite_api.finders.whisper.WhisperFinder | |
functions: | |
- graphite_api.functions.SeriesFunctions | |
- graphite_api.functions.PieFunctions | |
whisper: | |
directories: | |
- /opt/graphite/carbon/whisper | |
time_zone: UTC | |
CONFIG | |
fi | |
} | |
check_uwsgi_ini() { | |
## virtualenv's need this: | |
#home = /var/www/wsgi-scripts/env | |
if [[ ! -f ${GRAPHITE_API_CONFIG} ]] ; then | |
cat <<CONFIG > ${GRAPHITE_API_WSGI} | |
[uwsgi] | |
processes = 2 | |
http-socket = localhost:8001 | |
uid = 165 | |
gid = 165 | |
module = graphite_api.app:app | |
daemonize2 = /var/log/uwsgi-graphiteapi.log | |
env = GRAPHITE_API_CONFIG=${GRAPHITE_API_CONFIG} | |
CONFIG | |
fi | |
} | |
# do start Graphite-API under uWSGI | |
uwsgi --ini ${GRAPHITE_API_WSGI} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream myapp { | |
least_conn; | |
server unix:///var/run/uwsgi_myapp0.sock; | |
server unix:///var/run/uwsgi_myapp1.sock; | |
server unix:///var/run/uwsgi_myapp2.sock; | |
server unix:///var/run/uwsgi_myapp3.sock; | |
server unix:///var/run/uwsgi_myapp4.sock; | |
} | |
server { | |
listen 80; | |
server_name myapp.example.com; | |
location /static { | |
alias /usr/local/www/myapp/static; | |
} | |
location / { | |
uwsgi_pass myapp; | |
include uwsgi_params; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[unix_http_server] | |
file=/var/run/supervisor/supervisor.sock | |
[supervisord] | |
logfile=/var/log/supervisord.log ; (main log file;default $CWD/supervisord.log) | |
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) | |
logfile_backups=10 ; (num of main logfile rotation backups;default 10) | |
loglevel=info ; (log level;default info; others: debug,warn,trace) | |
pidfile=/var/run/supervisor/supervisord.pid ; (supervisord pidfile;default supervisord.pid) | |
nodaemon=false ; (start in foreground if true;default false) | |
minfds=1024 ; (min. avail startup file descriptors;default 1024) | |
minprocs=200 ; (min. avail process descriptors;default 200) | |
[rpcinterface:supervisor] | |
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | |
[supervisorctl] | |
serverurl=unix:///var/run/supervisor/supervisor.sock | |
history_file=~/.sc_history ; use readline history if available | |
[program:uwsgi_myapp] | |
directory=/usr/local/www/myapp/ | |
command=/usr/local/bin/uwsgi -s /var/run/%(program_name)s%(process_num)d.sock | |
--chmod-socket=666 --need-app --disable-logging --home=venv | |
--wsgi-file wsgi.py --processes 1 --threads 10 | |
stdout_logfile="syslog" | |
stderr_logfile="syslog" | |
startsecs=10 | |
stopsignal=QUIT | |
stopasgroup=true | |
killasgroup=true | |
process_name=%(program_name)s%(process_num)d | |
numprocs=5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment