Coder Social home page Coder Social logo

Comments (34)

pamelafox avatar pamelafox commented on August 12, 2024 1

Okay great! Whitenoise configuration can be a bit tricky, but that's what this repo does, so it should be possible. Another option is to store static assets in Azure storage. See https://github.com/tonybaloney/django-on-azure for an example of that.

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

Does that error prevent your app from running entirely, or is it just showing up in your logs? I have seen that in my Django logs as well, and I think it was from some health-check service pinging the app. My app ran fine for regular requests regardless of the error.

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

yes it prevents my app from running entirely.

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

the container is failing to startup.

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

2023-05-16T16:50:58.208716702Z _____
2023-05-16T16:50:58.208750502Z / _ \ __________ _________ ____
2023-05-16T16:50:58.208756002Z / /\ \__ / | _ __ _/ __ \
2023-05-16T16:50:58.208759802Z / | / /| | /| | /\ /
2023-05-16T16:50:58.208763202Z _
|__ /_____ _/ || __ >
2023-05-16T16:50:58.208767002Z / / /
2023-05-16T16:50:58.208770402Z A P P S E R V I C E O N L I N U X
2023-05-16T16:50:58.208773802Z
2023-05-16T16:50:58.208777002Z Documentation: http://aka.ms/webapp-linux
2023-05-16T16:50:58.208780302Z Python 3.9.16
2023-05-16T16:50:58.208783602Z Note: Any data outside '/home' is not persisted
2023-05-16T16:51:02.724503638Z Starting OpenBSD Secure Shell server: sshd.
2023-05-16T16:51:02.873986085Z App Command Line not configured, will attempt auto-detect
2023-05-16T16:51:03.365740893Z Starting periodic command scheduler: cron.
2023-05-16T16:51:03.365773193Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite
2023-05-16T16:51:03.706497645Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2023-05-16T16:51:03.717341313Z Build Operation ID: 6b282f1373b182e8
2023-05-16T16:51:03.719523227Z Oryx Version: 0.2.20230103.1, Commit: df89ea1db9625a86ba583272ce002847c18f94fe, ReleaseTagName: 20230103.1
2023-05-16T16:51:03.726991574Z Output is compressed. Extracting it...
2023-05-16T16:51:03.727875580Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8db562cef8266ed'...
2023-05-16T16:51:19.419586502Z App path is set to '/tmp/8db562cef8266ed'
2023-05-16T16:51:19.419668402Z Detected an app based on Django
2023-05-16T16:51:19.419675602Z Generating gunicorn command for 'core.wsgi'
2023-05-16T16:51:19.475224439Z Writing output script to '/opt/startup/startup.sh'
2023-05-16T16:51:20.515484842Z Using packages from virtual environment antenv located at /tmp/8db562cef8266ed/antenv.
2023-05-16T16:51:20.516864051Z Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8db562cef8266ed/antenv/lib/python3.9/site-packages'
2023-05-16T16:51:23.288289363Z [2023-05-16 16:51:23 +0000] [68] [INFO] Starting gunicorn 20.1.0
2023-05-16T16:51:23.335554247Z [2023-05-16 16:51:23 +0000] [68] [INFO] Listening at: http://0.0.0.0:8000 (68)
2023-05-16T16:51:23.336848755Z [2023-05-16 16:51:23 +0000] [68] [INFO] Using worker: sync
2023-05-16T16:51:23.354193459Z [2023-05-16 16:51:23 +0000] [71] [INFO] Booting worker with pid: 71
2023-05-16T16:51:31.352867232Z Code Profiler Installer is starting up
2023-05-16T16:51:31.353996338Z Waiting for the logs flag to be set
2023-05-16T16:51:31.355747449Z Cleaning up any existing status file which indicated signal handlers initialized status
2023-05-16T16:51:31.366873114Z Attempting to delete the signal_handler status file for instance id a7310b5f6b9b53a5216c40c337ca6ee44f0f35ed0e41d5917fa04d225aa29317
2023-05-16T16:51:31.370242134Z successfully deleted the status file
2023-05-16T16:51:31.372828349Z APPSETTING_WEBSITE_ENABLE_DEFAULT_CODE_PROFILER : None
2023-05-16T16:51:31.847051440Z Attempting to install the default code profiler.
2023-05-16T16:51:31.849227553Z viztracer would save traces to /tmp/a7310b_profiler_trace.json
2023-05-16T16:51:31.866368754Z Successfully installed code profiler.
2023-05-16T16:51:31.892575608Z Signal Handlers SIGUSR for needed code-profiler have been initialized for gunicorn process on instance a7310b5f6b9b53a5216c40c337ca6ee44f0f35ed0e41d5917fa04d225aa29317
2023-05-16T16:51:31.893999616Z Code Profiler Installer is exiting as installation is completed
2023-05-16T16:53:46.335577107Z Invalid HTTP_HOST header: '169.254.130.4:8000'. You may need to add '169.254.130.4' to ALLOWED_HOSTS.
2023-05-16T16:53:46.352196775Z Traceback (most recent call last):
2023-05-16T16:53:46.352229775Z File "/tmp/8db562cef8266ed/antenv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
2023-05-16T16:53:46.352241075Z response = get_response(request)
2023-05-16T16:53:46.352251175Z File "/tmp/8db562cef8266ed/antenv/lib/python3.9/site-packages/django/utils/deprecation.py", line 133, in call
2023-05-16T16:53:46.352261175Z response = self.process_request(request)
2023-05-16T16:53:46.352270375Z File "/tmp/8db562cef8266ed/antenv/lib/python3.9/site-packages/django/middleware/common.py", line 48, in process_request
2023-05-16T16:53:46.352280075Z host = request.get_host()
2023-05-16T16:53:46.352298175Z File "/tmp/8db562cef8266ed/antenv/lib/python3.9/site-packages/django/http/request.py", line 150, in get_host
2023-05-16T16:53:46.352302275Z raise DisallowedHost(msg)
2023-05-16T16:53:46.352306275Z django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '169.254.130.4:8000'. You may need to add '169.254.130.4' to ALLOWED_HOSTS.
2023-05-16T16:53:47.395274659Z Bad Request: /robots933456.txt
2023-05-16T16:53:47.412738830Z 169.254.130.1 - - [16/May/2023:16:53:47 +0000] "GET /robots933456.txt HTTP/1.1" 400 143 "-" "HealthCheck/1.0"

this is full log

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

I do see the error, but I have had the same error and my app has worked fine for subsequent requests. What do you see in the log when you make a request to the App Service URL?

My blog post about debugging Django on App Service may be helpful:
https://blog.pamelafox.org/2023/01/tips-for-debugging-django-app.html

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

2023-05-16T20:20:58.916Z INFO - Waiting for response to warmup request for container xness_1_0d205f84. Elapsed time = 33.3795964 sec

2023-05-16T20:22:47 No new trace in the past 1 min(s).
2023-05-16T20:23:47 No new trace in the past 2 min(s).
2023-05-16T20:20:24.788863021Z _____

2023-05-16T20:20:24.788921422Z / _ \ __________ _________ ____

2023-05-16T20:20:24.788926622Z / /\ \__ / | _ __ _/ __ \

2023-05-16T20:20:24.788930122Z / | / /| | /| | /\ ___/

2023-05-16T20:20:24.788933122Z _| /____ _/ || __ >

2023-05-16T20:20:24.788936422Z / / /

2023-05-16T20:20:24.788939322Z A P P S E R V I C E O N L I N U X

2023-05-16T20:20:24.788942323Z

2023-05-16T20:20:24.788945023Z Documentation: http://aka.ms/webapp-linux

2023-05-16T20:20:24.788948023Z Python 3.9.16

2023-05-16T20:20:24.788950923Z Note: Any data outside '/home' is not persisted

2023-05-16T20:20:27.190065138Z Starting OpenBSD Secure Shell server: sshd.

2023-05-16T20:20:27.389412588Z App Command Line not configured, will attempt auto-detect

2023-05-16T20:20:27.391040224Z App will launch in debug mode

2023-05-16T20:20:27.834337619Z Starting periodic command scheduler: cron.

2023-05-16T20:20:27.843287919Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -debugAdapter ptvsd -debugPort 49494

2023-05-16T20:20:28.024310959Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...

2023-05-16T20:20:28.028974367Z Build Operation ID: fe13e5ef0cd9d4bb

2023-05-16T20:20:28.031092320Z Output is compressed. Extracting it...

2023-05-16T20:20:28.031130421Z Oryx Version: 0.2.20230103.1, Commit: df89ea1db9625a86ba583272ce002847c18f94fe, ReleaseTagName: 20230103.1

2023-05-16T20:20:28.037251275Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8db5649f2cda642'...

2023-05-16T20:20:40.099652103Z App path is set to '/tmp/8db5649f2cda642'

2023-05-16T20:20:40.157026690Z Detected an app based on Django

2023-05-16T20:20:40.158191908Z Generating debugpy command for 'manage runserver --noreload --nothreading $HOST:$PORT'

2023-05-16T20:20:40.441395590Z Writing output script to '/opt/startup/startup.sh'

2023-05-16T20:20:41.418542671Z Using packages from virtual environment antenv located at /tmp/8db5649f2cda642/antenv.

2023-05-16T20:20:41.419848102Z Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8db5649f2cda642/antenv/lib/python3.9/site-packages'

2023-05-16T20:20:58.208066635Z Performing system checks...

2023-05-16T20:20:58.208154437Z

2023-05-16T20:21:02.422497012Z System check identified no issues (0 silenced).

2023-05-16T20:21:05.407655128Z May 16, 2023 - 20:21:05

2023-05-16T20:21:05.407694829Z Django version 4.2.1, using settings 'core.settings.prod'

2023-05-16T20:21:05.407700729Z Starting development server at http://0.0.0.0:8000/

2023-05-16T20:21:05.407712829Z Quit the server with CONTROL-C.

2023-05-16T20:21:05.416399808Z

2023-05-16T20:23:16.950020139Z Invalid HTTP_HOST header: '169.254.130.2:8000'. You may need to add '169.254.130.2' to ALLOWED_HOSTS.

2023-05-16T20:23:16.950066040Z Traceback (most recent call last):

2023-05-16T20:23:16.950073340Z File "/tmp/8db5649f2cda642/antenv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner

2023-05-16T20:23:16.950080540Z response = get_response(request)

2023-05-16T20:23:16.950084540Z File "/tmp/8db5649f2cda642/antenv/lib/python3.9/site-packages/django/utils/deprecation.py", line 133, in call

2023-05-16T20:23:16.950089040Z response = self.process_request(request)

2023-05-16T20:23:16.950093040Z File "/tmp/8db5649f2cda642/antenv/lib/python3.9/site-packages/django/middleware/common.py", line 48, in process_request

2023-05-16T20:23:16.950097240Z host = request.get_host()

2023-05-16T20:23:16.950101040Z File "/tmp/8db5649f2cda642/antenv/lib/python3.9/site-packages/django/http/request.py", line 150, in get_host

2023-05-16T20:23:16.950105040Z raise DisallowedHost(msg)

2023-05-16T20:23:16.950108840Z django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '169.254.130.2:8000'. You may need to add '169.254.130.2' to ALLOWED_HOSTS.

2023-05-16T20:23:17.026854655Z Bad Request: /robots933456.txt

2023-05-16T20:23:17.029669399Z [16/May/2023 20:23:17] "GET /robots933456.txt HTTP/1.1" 400 143

2023-05-16T20:24:43.200Z ERROR - Container xness_1_0d205f84 for site xness did not start within expected time limit. Elapsed time = 257.6634731 sec

2023-05-16T20:24:43.990Z ERROR - Container xness_1_0d205f84 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.

2023-05-16T20:24:44.226Z INFO - Stopping site xness because it failed during startup.

shows the same output

and here's the default docker log :

2023-05-16T20:20:24.788863021Z _____
2023-05-16T20:20:24.788921422Z / _ \ __________ _________ ____
2023-05-16T20:20:24.788926622Z / /\ \__ / | _ __ _/ __ \
2023-05-16T20:20:24.788930122Z / | / /| | /| | /\ /
2023-05-16T20:20:24.788933122Z _
|__ /_____ _/ || __ >
2023-05-16T20:20:24.788936422Z / / /
2023-05-16T20:20:24.788939322Z A P P S E R V I C E O N L I N U X
2023-05-16T20:20:24.788942323Z
2023-05-16T20:20:24.788945023Z Documentation: http://aka.ms/webapp-linux
2023-05-16T20:20:24.788948023Z Python 3.9.16
2023-05-16T20:20:24.788950923Z Note: Any data outside '/home' is not persisted
2023-05-16T20:20:27.190065138Z Starting OpenBSD Secure Shell server: sshd.
2023-05-16T20:20:27.389412588Z App Command Line not configured, will attempt auto-detect
2023-05-16T20:20:27.391040224Z App will launch in debug mode
2023-05-16T20:20:27.834337619Z Starting periodic command scheduler: cron.
2023-05-16T20:20:27.843287919Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -debugAdapter ptvsd -debugPort 49494
2023-05-16T20:20:28.024310959Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2023-05-16T20:20:28.028974367Z Build Operation ID: fe13e5ef0cd9d4bb
2023-05-16T20:20:28.031092320Z Output is compressed. Extracting it...
2023-05-16T20:20:28.031130421Z Oryx Version: 0.2.20230103.1, Commit: df89ea1db9625a86ba583272ce002847c18f94fe, ReleaseTagName: 20230103.1
2023-05-16T20:20:28.037251275Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8db5649f2cda642'...
2023-05-16T20:20:40.099652103Z App path is set to '/tmp/8db5649f2cda642'
2023-05-16T20:20:40.157026690Z Detected an app based on Django
2023-05-16T20:20:40.158191908Z Generating debugpy command for 'manage runserver --noreload --nothreading $HOST:$PORT'
2023-05-16T20:20:40.441395590Z Writing output script to '/opt/startup/startup.sh'
2023-05-16T20:20:41.418542671Z Using packages from virtual environment antenv located at /tmp/8db5649f2cda642/antenv.
2023-05-16T20:20:41.419848102Z Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8db5649f2cda642/antenv/lib/python3.9/site-packages'
2023-05-16T20:20:58.208066635Z Performing system checks...
2023-05-16T20:20:58.208154437Z
2023-05-16T20:21:02.422497012Z System check identified no issues (0 silenced).
2023-05-16T20:21:05.407655128Z May 16, 2023 - 20:21:05
2023-05-16T20:21:05.407694829Z Django version 4.2.1, using settings 'core.settings.prod'
2023-05-16T20:21:05.407700729Z Starting development server at http://0.0.0.0:8000/
2023-05-16T20:21:05.407712829Z Quit the server with CONTROL-C.
2023-05-16T20:21:05.416399808Z
2023-05-16T20:23:16.950020139Z Invalid HTTP_HOST header: '169.254.130.2:8000'. You may need to add '169.254.130.2' to ALLOWED_HOSTS.
2023-05-16T20:23:16.950066040Z Traceback (most recent call last):
2023-05-16T20:23:16.950073340Z File "/tmp/8db5649f2cda642/antenv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
2023-05-16T20:23:16.950080540Z response = get_response(request)
2023-05-16T20:23:16.950084540Z File "/tmp/8db5649f2cda642/antenv/lib/python3.9/site-packages/django/utils/deprecation.py", line 133, in call
2023-05-16T20:23:16.950089040Z response = self.process_request(request)
2023-05-16T20:23:16.950093040Z File "/tmp/8db5649f2cda642/antenv/lib/python3.9/site-packages/django/middleware/common.py", line 48, in process_request
2023-05-16T20:23:16.950097240Z host = request.get_host()
2023-05-16T20:23:16.950101040Z File "/tmp/8db5649f2cda642/antenv/lib/python3.9/site-packages/django/http/request.py", line 150, in get_host
2023-05-16T20:23:16.950105040Z raise DisallowedHost(msg)
2023-05-16T20:23:16.950108840Z django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: '169.254.130.2:8000'. You may need to add '169.254.130.2' to ALLOWED_HOSTS.
2023-05-16T20:23:17.026854655Z Bad Request: /robots933456.txt
2023-05-16T20:23:17.029669399Z [16/May/2023 20:23:17] "GET /robots933456.txt HTTP/1.1" 400 143

docker :

2023-05-16T20:20:17.080Z INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2023-05-16T20:20:25.537Z INFO - Initiating warmup request to container xness_1_0d205f84 for site xness
2023-05-16T20:20:42.223Z INFO - Waiting for response to warmup request for container xness_1_0d205f84. Elapsed time = 16.6860652 sec
2023-05-16T20:20:58.916Z INFO - Waiting for response to warmup request for container xness_1_0d205f84. Elapsed time = 33.3795964 sec
2023-05-16T20:24:43.200Z ERROR - Container xness_1_0d205f84 for site xness did not start within expected time limit. Elapsed time = 257.6634731 sec
2023-05-16T20:24:43.990Z ERROR - Container xness_1_0d205f84 didn't respond to HTTP pings on port: 8000, failing site start. See container logs for debugging.
2023-05-16T20:24:44.226Z INFO - Stopping site xness because it failed during startup.

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

I'll see if I can replicate with my clone of the repo. Have you made any changes, or is it from the latest version of the repo? (Which commit is yours on?)

By the way, the purpose of startup.sh is to take care of database migration. If you remove it, the app will then have an error starting up since the database tables won't exist.

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

I'm working on it Storefront

Not long ago I was able to deploy it successfully but I was working on dockerize the app then something happened after that I am unable to redeploy it.

If you don't mind please take a look at settings and workflow files. @pamelafox

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

I found this I think there's something wrong with the latest deployment stuff

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

I just re-deployed this repo (not your repo) using the Azure Developer CLI, and it deployed and ran successfully.

I notice your logs says 'App will launch in debug mode' and launches a development server, so perhaps you have a setting configured that's causing that?

You can see how our sample app is configured here:
https://github.com/Azure-Samples/msdocs-django-postgresql-sample-app/blob/main/infra/resources.bicep#L91

Here are what the logs look like:


2023-05-16T20:56:02.796542384Z    _____                               
2023-05-16T20:56:02.796581984Z   /  _  \ __________ _________   ____  
2023-05-16T20:56:02.796588484Z  /  /_\  \\___   /  |  \_  __ \_/ __ \ 
2023-05-16T20:56:02.796593084Z /    |    \/    /|  |  /|  | \/\  ___/ 
2023-05-16T20:56:02.796597584Z \____|__  /_____ \____/ |__|    \___  >
2023-05-16T20:56:02.796602084Z         \/      \/                  \/ 
2023-05-16T20:56:02.796606384Z A P P   S E R V I C E   O N   L I N U X
2023-05-16T20:56:02.796610484Z 
2023-05-16T20:56:02.796614384Z Documentation: http://aka.ms/webapp-linux
2023-05-16T20:56:02.796618484Z Python 3.10.10
2023-05-16T20:56:02.796622484Z Note: Any data outside '/home' is not persisted
2023-05-16T20:56:04.109566875Z Starting OpenBSD Secure Shell server: sshd.
2023-05-16T20:56:04.215513804Z Site's appCommandLine: startup.sh
2023-05-16T20:56:04.222107756Z Checking of startup.sh is a file
2023-05-16T20:56:04.222230457Z App command line is not a file on disk, using it as the startup command.
2023-05-16T20:56:04.603187240Z Starting periodic command scheduler: cron.
2023-05-16T20:56:04.604019847Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite -userStartupCommand 'startup.sh'
2023-05-16T20:56:04.688111105Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2023-05-16T20:56:04.692210537Z Build Operation ID: dacaf1c72605ce23
2023-05-16T20:56:04.693607648Z Oryx Version: 0.2.20230322.1, Commit: 6c04ec75685b441c9378c238b6491cf9812313db, ReleaseTagName: 20230322.1
2023-05-16T20:56:04.697338478Z Output is compressed. Extracting it...
2023-05-16T20:56:04.706080646Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8db564f4f01b12f'...
2023-05-16T20:56:11.203266257Z App path is set to '/tmp/8db564f4f01b12f'
2023-05-16T20:56:11.384725964Z Writing output script to '/opt/startup/startup.sh'
2023-05-16T20:56:11.552706952Z Using packages from virtual environment antenv located at /tmp/8db564f4f01b12f/antenv.
2023-05-16T20:56:11.553854762Z Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8db564f4f01b12f/antenv/lib/python3.10/site-packages'
2023-05-16T20:56:16.395225612Z Operations to perform:
2023-05-16T20:56:16.395275212Z   Apply all migrations: admin, auth, contenttypes, restaurant_review, sessions
2023-05-16T20:56:16.395432213Z Running migrations:
2023-05-16T20:56:16.395444213Z   No migrations to apply.
2023-05-16T20:56:18.206140313Z [2023-05-16 20:56:18 +0000] [69] [INFO] Starting gunicorn 20.1.0
2023-05-16T20:56:18.212944960Z [2023-05-16 20:56:18 +0000] [69] [INFO] Listening at: http://0.0.0.0:8000 (69)
2023-05-16T20:56:18.213017261Z [2023-05-16 20:56:18 +0000] [69] [INFO] Using worker: gthread
2023-05-16T20:56:18.224312739Z [2023-05-16 20:56:18 +0000] [70] [INFO] Booting worker with pid: 70
2023-05-16T20:56:18.244042375Z [2023-05-16 20:56:18 +0000] [71] [INFO] Booting worker with pid: 71
2023-05-16T20:56:21.333199953Z 169.254.129.1 - - [16/May/2023:20:56:21 +0000] "GET /robots933456.txt HTTP/1.1" 400 143 "-" "HealthCheck/1.0"

2023-05-16T21:00:46.830895247Z Request for index page received
2023-05-16T21:00:46.830972048Z 169.254.129.1 - - [16/May/2023:21:00:46 +0000] "GET / HTTP/1.1" 200 4987 "-" "AlwaysOn"

2023-05-16T21:02:39.882319725Z Request for index page received
2023-05-16T21:02:39.882368925Z 169.254.129.1 - - [16/May/2023:21:02:39 +0000] "GET / HTTP/1.1" 200 4987 "https://sandbox-67-2.reactblade-ms.portal.azure.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.68"
2023-05-16T21:02:40.192116140Z 169.254.129.1 - - [16/May/2023:21:02:40 +0000] "GET /static/fontawesome/css/all.min.b7739c263f52.css HTTP/1.1" 200 0 "https://msdocs-django-pg-lc6mh7ow3bnvo-app-service.azurewebsites.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.68"
2023-05-16T21:02:40.221384349Z 169.254.129.1 - - [16/May/2023:21:02:40 +0000] "GET /static/bootstrap/css/bootstrap.min.ea03e10ce769.css HTTP/1.1" 200 0 "https://msdocs-django-pg-lc6mh7ow3bnvo-app-service.azurewebsites.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.68"
2023-05-16T21:02:40.340697702Z 169.254.129.1 - - [16/May/2023:21:02:40 +0000] "GET /static/bootstrap/js/bootstrap.min.68a96bbb5731.js HTTP/1.1" 200 0 "https://msdocs-django-pg-lc6mh7ow3bnvo-app-service.azurewebsites.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.68"
2023-05-16T21:02:40.370475215Z 169.254.129.1 - - [16/May/2023:21:02:40 +0000] "GET /static/images/azure-icon.686cdf4140da.svg HTTP/1.1" 200 0 "https://msdocs-django-pg-lc6mh7ow3bnvo-app-service.azurewebsites.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.68"
2023-05-16T21:02:40.457413636Z 169.254.129.1 - - [16/May/2023:21:02:40 +0000] "GET /static/fontawesome/webfonts/fa-solid-900.e8a427e15cc5.woff2 HTTP/1.1" 200 0 "https://msdocs-django-pg-lc6mh7ow3bnvo-app-service.azurewebsites.net/static/fontawesome/css/all.min.b7739c263f52.css" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.68"
2023-05-16T21:02:41.005430654Z 169.254.129.1 - - [16/May/2023:21:02:40 +0000] "GET /static/favicon.fba186b4c652.ico HTTP/1.1" 200 0 "https://msdocs-django-pg-lc6mh7ow3bnvo-app-service.azurewebsites.net/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36 Edg/112.0.1722.68"

2023-05-16T21:05:47.010510248Z Request for index page received
2023-05-16T21:05:47.010586948Z 169.254.129.1 - - [16/May/2023:21:05:47 +0000] "GET / HTTP/1.1" 200 4987 "-" "AlwaysOn"

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

I'm using GitHub actions , that might cause that.

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

I've managed to start the container but , I'm having this problem
image

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

That looks like an error with your postgres connection. You shouldn't be connecting to localhost, you should be connecting to an actual URL. Check your settings.

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

I can migrate through ssh
image

that means it's connected to the db right?

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

image

it's using my production settings file but it's starting a development server... I'm not sure why it's happening.

re: okay... so this is the docker log, so I think it's okay! I mean it's inside docker

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

Interesting, it looks like it might be triggering the debug mode used for remote debugging in VS Code: microsoft/vscode-python#2045
It seems that might be once again triggered due to an environment variable, possibly APPSVC_TUNNEL_PORT ? What env variables are defined for your app?

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

no, there's no APPSVC_TUNNEL_PORT variable. But I had the Azure extension installed. I uninstalled the extension but now it's showing the same db error.

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

Here's the thing.... I'm using azure app service+ database ( postgres ) + cache.
When I'm deploying the app it's starting inside a container. my settings logic is if WEBSITE_HOSTNAME exists then it'll use production settings else it'll use development settings. But it's not getting the WEBSITE_HOSTNAME inside the container so it's using the development settings and it's looking for the database at localhost. that's why I'm getting this error... i guess
error.png

again, i can access/use the database ( eg: migration ) through ssh and it's working.

but at the domain endpoint it's exposing the container IP .

IDK what to do I've tried everything .

If you please look at my manage.py , wsgi.py, and workflow file ... if I did any mistake... ( oh... there's docker files inside the resource directory , could it be look for it and use it ? )

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

Are you using App Service with your own Docker container? When using App Service normally, the Oryx build service passes in WEBSITE_HOSTNAME in the docker run command, you can see that in the logs. If you're using App Service with your own container, then I don't know how that works, you perhaps need to specify WEBSITE_HOSTNAME yourself? I recommend looking carefully at your Environment variables in Configuration in the Portal.

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

I'm not using Docker right now (I removed the files ). I did set up the project setting as shown here ( this repo ).
In the container log, I see the WEBSITE_HOSTNAME variable,
image
I deleted my whole resources, created new resources, and deployed them via GitHub actions.
Still, I'm getting this error, I don't know why my production settings aren't being used.
image

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

I'm not sure what's happening that's causing it to use your development settings. Can you share what's under Configuration in the Portal? (Without sharing anything secure, like SECRET_KEY).

In particular, I notice there's a Remote Debugging setting, which should be off.

You could also upload the full Docker logs as attachments.

Here's what I see for a working Django app.
Screenshot 2023-05-18 at 9 34 03 AM

Screenshot 2023-05-18 at 9 34 12 AM Screenshot 2023-05-18 at 9 34 34 AM Screenshot 2023-05-18 at 9 34 40 AM

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

I'm using this service:
1
2 1
2 2
I've set up all configuration settings the same as yours, but if I turn off "Basic Authentication" then the Github action won't work (so I turned that on).
3 1
3 2
It's my configuration settings:
conf

after all that I got :
image
That means it's still using the dev settings ( I guess ).

Logs:

2023_05_18_lw1sdlwk0001ZA_default_docker.log.txt

2023_05_18_lw1sdlwk0001ZA_docker.log.txt

MyRepo

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

The most recent logs end in an error about 'startup.sh' not being found, which I see you recently added to your repository. Do the logs still claim 'startup.sh' is not found?

Does the 500 error page show all your Django settings below the traceback? You might also check the values of those settings to confirm it's definitely picking up dev vs. prod settings.

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

I've looked at your blog post and observed your applog and docker log , and I come to an understanding.... GitHub actions will build and create an artifact then it'll send that artifact to azure via ftp ( with the publisher profile credentials) . Then the artifact files will be compressed and store into a temporary directory. then the Oryx will generate a manifest file. Then a docker container will start and again Oryx will extract the output.tar.gz whatever inside the wwwroot and set the Python environment then it'll run the gunicorn and expose the ip:port.

but look at my logs

2023-05-18T19:36:21.417140999Z Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml' 2023-05-18T19:36:21.424693859Z Could not find operation ID in manifest. Generating an operation id... 2023-05-18T19:36:21.454578504Z Build Operation ID: feda2f5d-f1bc-47f8-8d16-0986c3c67c34 2023-05-18T19:36:21.688640284Z Oryx Version: 0.2.20230322.1, Commit: 6c04ec75685b441c9378c238b6491cf9812313db, ReleaseTagName: 20230322.1 2023-05-18T19:36:21.736940732Z Writing output script to '/opt/startup/startup.sh' 2023-05-18T19:36:21.826147967Z WARNING: Could not find virtual environment directory /home/site/wwwroot/antenv. 2023-05-18T19:36:21.826176667Z WARNING: Could not find package directory /home/site/wwwroot/__oryx_packages__. 2023-05-18T19:36:21.828265156Z /opt/startup/startup.sh: 23: startup.sh: not found

  1. Cound not find build manifest file at '/home/site/wwwroot/oryx-manifest.toml
  2. Could not find virtual environment directory /home/site/wwwroot/antenv.
  3. Could not find package directory /home/site/

I've checked the directory ( wwwroot) , there's just a output.tar.gz file inside it . no extracted files .
then again ssh is running on a temp/<somerandomtemdir>
and in ssh there's a activated antenv and migrations and other suff working just fine , i did even seed the db with custom command that means everything is working fine inside the temp dir ( ssh running )

ps: I've redeploy and sync 3/4 times there's no new docker log ... it deployed but no docker log generated.

I'm not sleeping for 3 days.. this is not important to me but I'm just obsessed with why it's not working ... i think I've got OCD . And thanks for your response . I might drop it . And I don't know why there's so small amount of resources on this deployment issue

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

I found something...

https://stackoverflow.com/questions/65321862/azure-web-app-deployed-to-tmp-folder-instead-of-wwwroot

https://github.com/Azure-App-Service/KuduLite/wiki/Python-Build-Changes

https://github.com/Azure-App-Service/ImageBuilder/issues/87

and I've tried this >
https://github.com/Azure-App-Service/ImageBuilder/issues/87#issuecomment-1171291286

I deploy with SCM_DO_BUILD_DURING_DEPLOYMENT=false
and then extracted the output.tar.gz ( which is previously built by Oryx with SCM_DO_BUILD_DURING_DEPLOYMENT=true )

the ssh ( or the environment did run in wwwroot )
but than again i got the error disallowed host

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

can you help with this issue ? @RyanHill-MSFT

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

I looked into this, and the error is in your configuration. You have two places where you override DJANGO_SETTINGS_MODULE: celery.py, and pytest.ini. When I removed those two overrides, I was able to deploy it fine. I think only celery.py removal is needed, but you can check yourself. That was definitely problematic since it got initialized in core/init.py.

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

The version I deployed is in this fork/branch:
https://github.com/Gradient-Ultra/Storefront/compare/main...pamelafox:Storefront:fixed-deploy?expand=1

I also added infra/ code so that you can deploy using the Azure Developer CLI if you prefer. Just run 'azd up'.

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

@vmagelo This issue can be closed, as there's no issue on our side.

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

one more thing, can you access /admin or any other URL?
@pamelafox

from msdocs-django-postgresql-sample-app.

pamelafox avatar pamelafox commented on August 12, 2024

No, they appear to 404. That would another Django configuration issue, however, not an Azure-specific issue. I suggest looking into your urls.py files as well as staticfiles configuration (if things work correctly locally).

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

image
my deployed project dir is /tmp/8db5af0576d495b#
but, whitenoise is searching files in site/wwwroot

from msdocs-django-postgresql-sample-app.

sabbir2609 avatar sabbir2609 commented on August 12, 2024

oh, sorry I think I get it. Thank you so much for your valuable time and response.

from msdocs-django-postgresql-sample-app.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.