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

Publish to Heroku is broken: "WARNING: You must pass the application as an import string to enable 'reload' or 'workers" #633

Closed
simonw opened this issue Nov 13, 2019 · 2 comments

Comments

@simonw
Copy link
Owner

@simonw simonw commented Nov 13, 2019

2019-11-13T16:27:59.821483+00:00 heroku[web.1]: Starting process with command `datasette serve --host 0.0.0.0 -i fixtures.db --cors --port 36817 --inspect-file inspect-data.json`
2019-11-13T16:28:01.856471+00:00 heroku[web.1]: State changed from starting to crashed
2019-11-13T16:28:01.750253+00:00 app[web.1]: Serve! files=() (immutables=('fixtures.db',)) on port 36817
2019-11-13T16:28:01.771524+00:00 app[web.1]: WARNING:  You must pass the application as an import string to enable 'reload' or 'workers'.
2019-11-13T16:28:01.837839+00:00 heroku[web.1]: Process exited with status 1
@simonw

This comment has been minimized.

Copy link
Owner Author

@simonw simonw commented Nov 13, 2019

The problem is this code in uvicorn: https://github.com/encode/uvicorn/blob/020dd085a0a5b609f14ddd2b36fc0a97ba4df019/uvicorn/main.py#L297-L302

    if (config.reload or config.workers > 1) and not isinstance(app, str):
        logger = logging.getLogger("uvicorn.error")
        logger.warn(
            "You must pass the application as an import string to enable 'reload' or 'workers'."
        )
        sys.exit(1)

From this commit 4 days ago: encode/uvicorn@b034f7a - see Uvicorn encode/uvicorn#478 and encode/uvicorn#481

This is breaking because --workers "Defaults to the $WEB_CONCURRENCY environment variable if available" - and it turns out on Heroku WEB_CONCURRENCY is set to 2 by default!

@simonw

This comment has been minimized.

Copy link
Owner Author

@simonw simonw commented Nov 13, 2019

Short term fix: set --workers=1 when publishing with Heroku. Or even easier - set WEB_CONCURRENCY to 1.

@simonw simonw closed this in f524510 Nov 13, 2019
simonw added a commit that referenced this issue Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.