Skip to content

Verify wsgi.py copy before reloading the webapp - #23

Merged
copelco merged 2 commits into
caktus:mainfrom
tim-schilling:fix/wsgi-copy-verification
Aug 27, 2026
Merged

Verify wsgi.py copy before reloading the webapp#23
copelco merged 2 commits into
caktus:mainfrom
tim-schilling:fix/wsgi-copy-verification

Conversation

@tim-schilling

@tim-schilling tim-schilling commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Consoles are reused across API calls, so a relative cp source path can silently copy from the wrong cwd, and run_command never checked exit status at all. Either failure mode left the deploy reporting success while PythonAnywhere kept serving its placeholder wsgi app. The destination filename also needs a lowercased username: PythonAnywhere only looks for the lowercased form regardless of the account's actual casing.

Fixes #21


This fix was generated with Claude (Sonnet if that matters)

Consoles are reused across API calls, so a relative cp source path can
silently copy from the wrong cwd, and run_command never checked exit
status at all. Either failure mode left the deploy reporting success
while PythonAnywhere kept serving its placeholder wsgi app. The
destination filename also needs a lowercased username: PythonAnywhere
only looks for the lowercased form regardless of the account's actual
casing.

@copelco copelco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! thanks @tim-schilling

non-zero status.
"""
response = self.send_input(f"{command}\n")
full_command = f'{command}; echo "{self.EXIT_STATUS_MARKER}:$?"'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

15:06 ~ $ curl -fsSL https://raw.githubusercontent.com/caktus/dsd-pythonanywhere/refs/heads/main/scripts/setup.sh | bash -s -- https://github.com/copelco/dsd-testproj.git dsd-testproj blo
g; echo "DSD_EXIT_STATUS:$?"
Cloning repository...
Cloning into 'dsd-testproj'...
--snip--
127 static files copied to '/home/copelcobeginner/dsd-testproj/static'.
Setup complete!!!
DSD_EXIT_STATUS:0
15:09 ~ $

# cp can "succeed" while copying the wrong file (e.g. an unexpected
# cwd), so confirm the destination actually matches the source before
# declaring the deploy successful.
verify_cmd = f"cmp -s {wsgi_src} {wsgi_dest} && echo COPY_VERIFIED || echo COPY_FAILED"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice-- worked for me!

15:32 ~ $ cmp -s /home/copelcobeginner/dsd-testproj/blog/wsgi.py /var/www/copelcobeginner_pythonanywhere_com_wsgi.py && echo COPY_VERIFIED || echo COPY_FAILED; echo "DSD_EXIT_STATUS:$?"
COPY_VERIFIED
DSD_EXIT_STATUS:0

@copelco
copelco merged commit e521d50 into caktus:main Aug 27, 2026
2 checks passed
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.

_copy_wsgi_file() can silently fail, serving the PythonAnywhere placeholder

2 participants