Gunicorn error: unrecognized arguments: run:app (using waitress and nginx)

Viewed 17

I am using an AWS ubuntu machine to run a Flask Blueprints application. I have been able to run in development mode where my service file has an ExecStart like this: ExecStart=/home/ubuntu/environments/venv_wsh06api/bin/gunicorn -w 3 -b 0.0.0.0:8001 run:app

But now I want to run using waitress. I have tried every iteration I can think of: gunicorn waitress -w 3 -b 0.0.0.0:8080 run:app

and each is giving some version of “gunicorn: error: unrecognized arguments: run:app”. It’s always last argument where I am telling what app to run that is being called out as the error.

I have seen some very elaborate run.py files but none seem to apply to me. I know there are a few other posts and even a Medium article that closely address my needs. I’ve parsed through them in detail alternating things and still not getting anywhere.

Any advice greatly appreciated. Even a suggestion where to look would be wonderful. Thanks.

wsh06dev03.service

[Unit]
Description=Gunicorn instance to serve wsh06api3.service in venv_wsh06api.
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/applications/whatSticks06api
Environment="PATH=/home/ubuntu/environments/venv_wsh06api/bin"
ExecStart=/home/ubuntu/environments/venv_wsh06api/bin/gunicorn waitress -w 3 -b 0.0.0.0:8080 run:app

[Install]
WantedBy=multi-user.target

run.py

from app_package import create_app
from waitress import serve

app = create_app()

if __name__ == '__main__':
    serve(app, host='0.0.0.0', port=8080)

init.py

from flask import Flask
from wsh_config import ConfigDev, ConfigProd
import logging
from logging.handlers import RotatingFileHandler
import os

config_object = ConfigDev()

logs_dir = os.path.join(os.getcwd(), 'logs')

if not os.path.exists(logs_dir):
    os.makedirs(logs_dir)

#Setting up Logger


def create_app():
    app = Flask(__name__)
    app.config.from_object(config_object)

    from app_package.scheduler.routes import sched_route
    
    app.register_blueprint(sched_route)
    
    return app      

0 Answers
Related