Skip to content

Conversation

dhensen
Copy link

@dhensen dhensen commented Jun 3, 2025

This does not work as expected:

@app.main_process_start
async def update_server_name(app, loop):
    some_url = some_reason()
    if some_url:
        app.update_config({"SERVER_NAME": some_url})

Problem

I would have expected my SERVER_NAME update to have propagated to workers, especially since doing this on main_process_start, but this is not the case. Because I have SANIC_SERVER_NAME env var set to some different value, all my workers still take that value, even though I just updated it with a new value.

Solution

With this PR, code above now works, and I can optionally change my SERVER_NAME at main_process_start and all my workers will have the correct SERVER_NAME.

@dhensen dhensen requested a review from a team as a code owner June 3, 2025 14:15
@dhensen dhensen force-pushed the passthru-server-name branch from 94d2607 to 8ce2404 Compare June 3, 2025 14:17
@dhensen dhensen marked this pull request as draft June 6, 2025 16:13
@dhensen
Copy link
Author

dhensen commented Jun 6, 2025

Converted to draft: when auto_reload=True this method does not update SERVER_NAME.
False alarm, I got fooled by my logs. Scrolled up too far, this scroll issue happened consistently 5 times when double checking. 😓

BTW: any idea why all those checks are failing? I see lint errors on files I did not touch.

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

Successfully merging this pull request may close these issues.

1 participant