GithubHelp home page GithubHelp logo

paolo-de-rosa / tornado-production-skeleton Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bdarnell/tornado-production-skeleton

0.0 2.0 0.0 331 KB

Simple example of a Tornado app in production

tornado-production-skeleton's Introduction

Overview

This is a skeletal example of one way to run a Tornado application in production. It currently covers running the application under Supervisor. Future additions may include automating initial setup and deploying new code (e.g. with Fabric) and running multiple processes behind a proxy (e.g. nginx).

Code layout

chat directory

This is our application; it's just the chat demo from the Tornado distribution.

third_party directory

This directory contains third-party modules we depend on, such as Tornado. Including the module directly in the codebase ensures that updates to these modules can be deployed as a single unit with the application code rather than a separate step (note that this really only makes sense for pure-python modules; C modules like pycurl are probably best managed externally).

Tornado is included as a git submodule; this means that after cloning this repository you must run git submodule update --init, and re-run git submodule update when the version of tornado being used has changed.

sitecustomize.py

sitecustomize.py is the magic that makes the third_party directory work (together with .pth files like third_party/tornado.pth). Simply point your PYTHONPATH at the directory containing sitecustomize.py and third_party will be added to the path automatically. The magic that makes this work is the site module, see http://docs.python.org/library/site.html. The site module is imported when python is initialized, it appends site-specific paths to the module search path.

production directory

This directory contains scripts used for Supervisor and other production services.

Setup instructions

All of these steps should be run as the user the app will be running as (except installing Supervisor).

  1. Install supervisor (e.g. sudo easy_install supervisor).
  2. Create directories: mkdir -p ~/logs ~/apps/tornado-production-skeleton
  3. Make this directory available at ~/apps/tornado-production-skeleton/current (either copy it into that location or use a symlink)
  4. Set up supervisor files in ~. Note that supervisord.conf is a copy because it changes rarely and can be shared by multiple projects, while chat.supervisor is a symlink to the current code. cp ~/apps/tornado-production-skeleton/current/production/supervisord.conf ~; ln -s apps/tornado-production-skeleton/current/production/chat.supervisor ~
  5. Run supervisord (in your home directory)

Usage notes

  • After each reboot, supervisord will need to be restarted. (TODO: instructions on making this happen automatically)
  • Run supervisorctl update after any change to the supervisor config files. To restart the servers when the supervisor config files have not changed, use supervisorctl restart chat:*
  • Use supervisorctl status to check on the status of the process. Once the program starts its logs are written to ~/logs, but if it crashes on startup you'll have to ask supervisor for the output: supervisorctl tail chat:chat-8000 stderr

tornado-production-skeleton's People

Contributors

bdarnell avatar stephenbalaban avatar

Watchers

 avatar  avatar

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.