Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates and digital ocean #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
This is an example Tornado app I set up for my post about running [Tornado](http://www.tornadoweb.org/) on [Linode](http://www.linode.com/), which you can read [here](http://chase.io/post/17197274701).

*Note: This also works on Digital Ocean :)
37 changes: 3 additions & 34 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,16 @@ http {
server 127.0.0.1:8003;
}

include /etc/nginx/mime.types;
default_type application/octet-stream;

include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;

keepalive_timeout 65;
proxy_read_timeout 200;
types_hash_max_size 2048;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/html text/css text/xml
application/x-javascript application/xml
application/atom+xml text/javascript;

# Only retry if there was a communication error, not a timeout
# on the Tornado server (to avoid propagating "queries of death"
# to all frontends)
proxy_next_upstream error;

server {
listen 80;

# Allow file uploads
client_max_body_size 50M;

location static/ {
root /srv/www/domain.com/tornado-linode/;
if ($query_string) {
expires max;
}
}
location = /favicon.ico {
rewrite (.*) /static/favicon.ico;
}
location = /robots.txt {
rewrite (.*) /static/robots.txt;
}

location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
Expand Down
43 changes: 28 additions & 15 deletions conf/supervisord.conf
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
# -*- conf -*-
[include]
files = *.supervisor

[supervisord]
[unix_http_server]
file=/tmp/supervisor.sock

[supervisorctl]
serverurl = unix://supervisord.sock

[unix_http_server]
file = supervisord.sock
serverurl=unix:///tmp/supervisor.sock

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisord]
logfile = /tmp/supervisord.log
logfile_maxbytes = 50MB
logfile_backups=10
loglevel = info
pidfile = /tmp/supervisord.pid
nodaemon = false
minfds = 1024
minprocs = 200
umask = 022
user = root
identifier = supervisor
directory = /tmp
nocleanup = true
childlogdir = /tmp
strip_ansi = false

[program:main]
process_name = main-%(process_num)s
command = python /srv/www/domain.com/tornado-linode/main.py
--port=%(process_num)s
--log_file_prefix=%(here)s/logs/%(program_name)s-%(process_num)s.log
numprocs = 4
numprocs_start = 8000
numprocs=4
numprocs_start=8000
command=python /srv/www/tornado-linode/main.py --port=%(process_num)02d
process_name = %(program_name)s_%(process_num)02d
autorstart=true
autorestart=true
startsecs=10
startretries=36
4 changes: 3 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import logging
import tornado
import tornado.ioloop
from tornado.options import define, options, logging
from tornado.options import define, options
import tornado.web

define("port", default=8888, help="run on the given port", type=int)
Expand Down