Hi, I'm really fascinated by python bottle. I was able to make it run on a small account on aruba.it where you have only cgi-bin. But I now realize that Opalstack has tons of resources and more sophisticated way to run bottle. Is somebody here able to write down a basic how-to on how to run python bottle properly on Opalstack behind Nginx, with uWsgi etc.? Thanks!

  • sean replied to this.

    giampiero here's one way to run Bottle on uWSGI here at Opalstack:

    1. Create a new uWSGI app via your Opalstack dashboard.
    2. Upload your Bottle app to the uWSGI app directory. Here's the basic app that I'm using for this example:

      # app.py
      import bottle
      
      app = application = bottle.Bottle()
      
      @app.route('/')
      def hello():
          return "Hello World!"
      
      if __name__ == '__main__':
          bottle.run(app, host='localhost', port=55555)
    1. Modify the app's uwsgi.ini to point it at the Bottle app (ie app.py in this example, be sure to change 55555 to your app's assigned port):

      [uwsgi]
      master = True
      http-socket = 127.0.0.1:55555
      virtualenv = /home/shelluser/apps/appname/env/
      daemonize = /home/shelluser/logs/appname/uwsgi.log
      pidfile = /home/shelluser/apps/appname/tmp/uwsgi.pid
      workers = 2
      threads = 2
      wsgi-file = /home/shelluser/apps/appname/app.py
      touch-reload = /home/shelluser/apps/appname/app.py
    1. Restart the app:

      /home/shelluser/apps/appname/stop
      sleep 2
      /home/shelluser/apps/appname/start

    You're done! Your Bottle app is now being served by uWSGI.

    Sean did it again! It works great. Thanks a lot again :-)

    Mastodon