Wheatserver

A C Implemented WSGI Server.


Project maintained by yuyuyu101 Hosted on GitHub Pages — Theme by mattgraham

Wheatserver(Alpha)

Full stack sync/asyc(wait) IO Application Framework, help you build your own application server.

You can use Wheatserver to develop web server, application proxy server and db proxy server etc. You will enjoy using sync programming model to have great performance under async model.

Now supporting WSGI, Static file distribute and Redis distribute.

中文文档

Feature

Workers: Sync Worker and Async Worker

Protocol: Http 1.0 and Http 1.1, Redis protocol

Application Server: WSGI support and static file support both under Http, Redis-cluster app support under Redis protocol

Build

Requestments: python, python-dev

Support Platform: Linux, Macosx

Support Web Service: WSGI

shell > cd wheatserver

shell > cd src

shell > make

Run

-./wheatserver --app-project-path {your app path } --app-project-name {app filename} --app-name {callable object}

Config

Attention: you must specify needed options under your choosing protocol

See wheatserver.conf

WSGI Example(Sample)

#sample.py which is in the wheatserver/src
HELLO_WORLD = b"Hello world!\n"

def simple_app(environ, start_response):
    """Simplest possible application object"""
    status = '200 OK'
    response_headers = [('Content-type', 'text/plain')]
    start_response(status, response_headers)
    return [HELLO_WORLD]

-./wheatserver --app-project-name sample --app-name simple_app

WSGI Example(Django)

-My Django Project Directory:

|-signup
   |-wsgi.py
   |-bin
   |-include
   |-lib
   |-signup
   |---activity
   |-----fixtures
   |-----static
   |-------css
   |-------img
   |-------js
   |---assets
   |-----static
   |---benefits
   |-----templatetags
   |---finance
   |-----templatetags
   |---fixtures
   |---logs
   |---match
   |-----......
   |---media
   |-----......
   |---snapboard
   |-----.......
   |---specialist
   |-----static
   |-------css
   |-------js
   |-----templates
   |-------admin
   |---------specialist
   |---static
   |---templates
   |-----......
   |---third_user
   |-----static
   |---settings.py
   |---urls.py

wsgi.py at the top of tree is the entry of Django WSGI.

import os, sys

sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'signup'))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "signup.settings")

# This application object is used by the development server
# as well as any WSGI server configured to use this file.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

-shell> ./wheatserver --app-project-path /Users/abcd/signup/ --app-module-name wsgi --app-name application

Admin management

shell > client/client.py

enter help to get command list and description

Signals for controlling

# using reload to send the signal
kill -HUP `cat /tmp/wheatserver.pid`
# using kill to send the signal
kill -INT `cat /tmp/project-master.pid`
Signal Description
SIGHUP reload configuration file, gracefully reload all the workers and the master process
SIGTERM brutally kill all the workers and the master process
SIGINT brutally kill the workers and the master process
SIGQUIT gracefully kill the workers and the master process
SIGUSR1 print statistics
SIGUSR2 reexec the entire master process and spawn workers
SIGTTIN add one to workernumber
SIGTTOU subtraction of one from workernumber
SIGWINCH only gracefully kill the workers and the master process backend