tonybaloney / django-on-azure

Resources for my Django on Azure workshop at PyCon US 2021
MIT License
19 stars 6 forks source link

The container fails to start correctly #28

Open ptkasper opened 1 year ago

ptkasper commented 1 year ago

I tried launching the app with "azd up --template https://github.com/tonybaloney/django-on-azure" and everything seemed to run smoothly (the command reported success) but it seems that the container startup script fails.

container-error

The app logs show this:

2023-03-14T11:14:56.389435503Z A P P S E R V I C E O N L I N U X 2023-03-14T11:14:56.389439103Z 2023-03-14T11:14:56.389442303Z Documentation: http://aka.ms/webapp-linux 2023-03-14T11:14:56.389445603Z Python 3.11.1 2023-03-14T11:14:56.389449403Z Note: Any data outside '/home' is not persisted 2023-03-14T11:14:59.257769126Z Starting OpenBSD Secure Shell server: sshd. 2023-03-14T11:14:59.438615395Z Site's appCommandLine: startup.sh 2023-03-14T11:14:59.439742739Z Checking of startup.sh is a file 2023-03-14T11:14:59.447250432Z App command line is not a file on disk, using it as the startup command. 2023-03-14T11:15:00.029772501Z Starting periodic command scheduler: cron. 2023-03-14T11:15:00.038175430Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand 'startup.sh' 2023-03-14T11:15:00.176289628Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it... 2023-03-14T11:15:00.182870685Z Build Operation ID: |3zZdGH1a6uc=.13be3d53_ 2023-03-14T11:15:00.185025269Z Oryx Version: 0.2.20230103.1, Commit: df89ea1db9625a86ba583272ce002847c18f94fe, ReleaseTagName: 20230103.1 2023-03-14T11:15:00.185424685Z Output is compressed. Extracting it... 2023-03-14T11:15:00.187661572Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8db246ef010923b'... 2023-03-14T11:15:12.026214654Z App path is set to '/tmp/8db246ef010923b' 2023-03-14T11:15:12.167685360Z Writing output script to '/opt/startup/startup.sh' 2023-03-14T11:15:16.672848181Z Using packages from virtual environment antenv located at /tmp/8db246ef010923b/antenv. 2023-03-14T11:15:16.674105429Z Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8db246ef010923b/antenv/lib/python3.11/site-packages' 2023-03-14T11:15:32.687288295Z /tmp/8db246ef010923b/antenv/lib/python3.11/site-packages/django/conf/init.py:240: RemovedInDjango50Warning: The USE_L10N setting is deprecated. Starting with Django 5.0, localized formatting of data will always be enabled. For example Django will display numbers and dates using the format of the current locale. 2023-03-14T11:15:32.687361998Z warnings.warn(USE_L10N_DEPRECATED_MSG, RemovedInDjango50Warning) 2023-03-14T11:15:34.161623237Z Unknown command: 'migrate\r'. Did you mean migrate? 2023-03-14T11:15:34.161689340Z Type 'manage.py help' for usage. 2023-03-14T11:15:36.872517830Z 2023-03-14T11:15:36.873356763Z Error: No application module specified. 2023-03-14T11:15:37.185639076Z /tmp/8db246ef010923b/startup.sh: 3: -: not found 2023-03-14T11:15:37.192942964Z /tmp/8db246ef010923b/startup.sh: 4: --chdir=/home/site/wwwroot: not found 2023-03-14T11:15:40.371Z ERROR - Container app-arlanz44sti7y_1_3d604f8f for site app-arlanz44sti7y has exited, failing site start 2023-03-14T11:15:40.447Z ERROR - Container app-arlanz44sti7y_1_3d604f8f didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.

tonybaloney commented 1 year ago

Thanks for reporting this issue, what Operating System did you run the command from?

It looks like it injected a CRLF in the startup.sh script for some reason. Git can do this on Windows when you check out a repo if the autocrlf command is on https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings#global-settings-for-line-endings

To check the line endings, in VS Code (and most editors) look at the file:

screenshot 2023-03-15 at 09 53 39

Because the host system is Linux, it needs to remain LF

ptkasper commented 1 year ago

Hi, Sounds like the correct conclusion as I ran the command from Win10.

Kr, Petri


Kohteesta: Anthony Shaw @.> Lähetetty: keskiviikkona 15. maaliskuuta 2023 klo 0.55 Vastaanottaja: tonybaloney/django-on-azure @.> Kopio: Petri K. @.>; Author @.> Aihe: Re: [tonybaloney/django-on-azure] The container fails to start correctly (Issue #28)

Thanks for reporting this issue, what Operating System did you run the command from?

It looks like it injected a CRLF in the startup.sh script for some reason. Git can do this on Windows when you check out a repo if the autocrlf command is on https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings#global-settings-for-line-endingshttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.github.com%2Fen%2Fget-started%2Fgetting-started-with-git%2Fconfiguring-git-to-handle-line-endings%23global-settings-for-line-endings&data=05%7C01%7C%7C7e63b345942f45a6b12008db24df356a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638144313316053434%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=0Jo7xdCZ3pOfMKagCBpMIxpAjO%2BoRrBMwrLo6lUBVoQ%3D&reserved=0

To check the line endings, in VS Code (and most editors) look at the file:

[screenshot 2023-03-15 at 09 53 39]https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F1532417%2F225159830-0374d973-c44b-41ca-a368-e6b39757bc43.png&data=05%7C01%7C%7C7e63b345942f45a6b12008db24df356a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638144313316053434%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=RYq80FasnSbT45GQhic88acNVuGoZL6%2BQRldDpRi4%2Fk%3D&reserved=0

Because the host system is Linux, it needs to remain LF

— Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftonybaloney%2Fdjango-on-azure%2Fissues%2F28%23issuecomment-1468975149&data=05%7C01%7C%7C7e63b345942f45a6b12008db24df356a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638144313316053434%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=oPPBVXbog9gTiyCPnpcnNUpHbNBWrAMqVm7guNKZZRU%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAL4FKRRKWULJ26MGIZC5HRDW4DZOBANCNFSM6AAAAAAV2JWGDE&data=05%7C01%7C%7C7e63b345942f45a6b12008db24df356a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638144313316053434%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Up9Nw5Qd3ntXoGkG8YVcBSpeEtPegPjlEwttSQ6XaY4%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>