简体   繁体   中英

How to deploy Bottle app on uWSGi using Emperor Mode

I m trying to deploy a Bottle App using the uWSGi in Emperor mode.

demo.py

import os
from bottle import Bottle, route, run

app=Bottle()

@app.route('/index')
def index():
    return "Hello world! "

@app.route('/:name')
def hello(name):
    return "hello %s" % name

# Mod WSGI launch
os.chdir(os.path.dirname(file))
application = bottle.default_app()

demo.ini

[uwsgi]
# Variables
base = /opt/apps/webapp/demo
app = demo
# Geneic Config
plugins=http,python
home = /opt/apps/webapp/demo
pythonpath=%(base)
socket = /tmp/%n.sock
module = %(app)
logto = /var/log/uwsgi/%n.log

The out put in the log file

gracefully (RE)spawned uWSGI master process (pid: 2414)
spawned uWSGI worker 1 (pid: 2646, cores: 1)
[pid: 2646|app: -1|req: -1/1] 10.0.0.240 () {40 vars in 688 bytes} [Sat Oct 13 15:00:00 2012] GET /demo => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
announcing my loyalty to the Emperor...
[pid: 2646|app: -1|req: -1/2] 10.0.0.240 () {40 vars in 688 bytes} [Sat Oct 13 15:00:05 2012] GET /demo => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)
[pid: 2646|app: -1|req: -1/3] 10.0.0.240 () {42 vars in 719 bytes} [Sat Oct 13 15:00:26 2012] GET /demo => generated 48 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 63 bytes (0 switches on core 0)

But on browser i still see this error

uWSGI Error

Python application not found

Please help

I finally able to found the answer and it seems it has been a silly mistake. I was calling

http://localhost/demo 

where as it should be

http://localhost/demo/demo

ie

http://localhost/{app_name}/{route_name}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM