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

run bottery in production #129

Closed
romulocollopy opened this issue Feb 10, 2018 · 3 comments
Closed

run bottery in production #129

romulocollopy opened this issue Feb 10, 2018 · 3 comments

Comments

@romulocollopy
Copy link

I'd like to discuss how is the best way to deploy Bottery.

It is already possible to run bottery as a python command in uWsgi

$ uwsgi --http :8000 --py bot.py --master --processes 4 --threads 3 

or with gunicorn and aiohttp.worker.GunicornWebWorker

$ gunicorn bot:bot.server -b 127.0.0.1:8000 --worker-class aiohttp.worker.GunicornWebWorker

In booth cases, bot.run(server_port=7000) is called to start and configure Bottery.
Maybe we could extract part of runmethod for someting called start_app to avoid some unnecessary calls, as self.loop.run_forever() and server creation with asincio that is already handled by gunicorn.

bot.run() could call bot.start_app() and handle the additional steps to run the development server

I'd suggest an usage like:

#! /usr/bin/env python
from bottery import Bottery

SERVER_PORT = 7000

bot = Bottery(settings_module="mysettings")

@bot.patterns.regex('^.*$')
def parrot(message):
    return message

if __name__ == '__main__':
    bot.run(server_port=SERVER_PORT)
else:
    bot.start_app()
@romulocollopy
Copy link
Author

@rougeth if you agree with this approach, please assingn me to the issue that I'll prepare a PR

@rougeth
Copy link
Owner

rougeth commented Feb 24, 2018

@romulocollopy how the gunicorn handles the server creation? this is one of the parts we don't need, right? https://github.com/rougeth/bottery/blob/master/bottery/bottery.py#L85-L91

I believe this change should be fine! 👍

@rougeth
Copy link
Owner

rougeth commented Apr 23, 2018

We now have a wsgi.py file to serve the projects using Bottery. It isn't on docs yet, but it's on the checklist at #143.

@rougeth rougeth closed this as completed Apr 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants