GithubHelp home page GithubHelp logo

docker_bootstrap's Introduction

Docker bootstrapper for python projects

Helps setting up logging and rsyslogd.

Rsyslog will be listening on the standard /dev/log socket and forwarding everything to logentries.

The bootstrap() turns the caller process into circusd and thus the function never returns.

Usage:

  1. add docker_bootstrap to your requirements

  2. drop your circus.ini file in the current dir

  3. Write a bootstrap.py module with the following contents:

    from docker_bootstrap import bootstrap
    
    bootstrap(log_level='WARNING', logentries_token='adsf', rsyslog_debug=False)
    
  4. in your Dockerfile add a ENTRYPOINT python bootstrap.py

  5. in your python code call: docker_bootstrap.setup_logging() and subsequently configure logging with disable_existing_loggers=False

The bootstrapper will spawn rsyslogd and circus for you.

Sample circusd config

[watcher:web]
cmd = uwsgi
args = uwsgi.ini
copy_env = True
use_sockets = True
send_hup = True
stop_signal = QUIT

stderr_stream.class = FileStream
stderr_stream.filename = /err.log
stderr_stream.max_bytes = 1000000
stderr_stream.backup_count = 4

stdout_stream.class = FileStream
stdout_stream.filename = /out.log
stdout_stream.max_bytes = 1000000
stdout_stream.backup_count = 4

[circus]
logoutput = syslog:///dev/log?local7

Sample uwsgi config

[uwsgi]
http-socket = :8080
master = true
processes = 4
module = my_proj.wsgi:application
logger = syslog

Testing locally

To log to the console instead of rsyslog, call bootstrap(rsyslog=False, console=True, circus=False); it will also prevent spawning of rsyslogd and circus.

Usually bootstrap() should be called by the testcase setup logic.

docker_bootstrap's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.