Reputation: 81
TL;DR: While trying to deploy a Django application on Azure web app running with Python 3.11 i'm getting this fatal error and the Azure web app is unable to start:
Error: [Errno 2] No such file or directory: '/etc/runit/runsvdir/default/ssh/log/supervise'
Long explanation:
I'm currently trying to deploying a Django Application on Azure Web apps.
Since i'm running the latest python version, the Web app is a configured as following:
i'm currently deploying the code by Zipping the project and running the following Azure command in the Cloud shell (or in the pipeline, is the same stuff):
az webapp deploy --subscription "My supersecret subscription" --resource-group "secret" --name "secret" --src-path my_project_zipped.zip --clean true --restart true
Moreover, since i want to create a virtual environment i must configure some environment variables that are handling the deploy life-cicle (oryx build ecc.). Here's the list:
Here's the current folder structure:
MYAPPLICATION:
│ manage.py
│ requirements.txt
│
├───deployments
│ │ azure-pipelines.yml
│ │ __init__.py
│ │
│ ├───Dev
│ │ │ deploy.sh
│ │ │ dev_settings.py
│ │ │ __init__.py
│ │ │
│ │
│ ├───Local
│ │ │ .env
│ │ │ dotenv.json
│ │ │ local_settings.py
│ │ │ __init__.py
│ │ │
│ │
│ ├───Prod
│ │ │ deploy.sh
│ │ │ prod_settings.py
│ │ │ __init__.py
│ │ │
│ │
│ ├───QA
│ │ │ deploy.sh
│ │ │ qa_settings.py
│ │ │ __init__.py
│ │ │
│ │
│ ├───Test
│ │ │ deploy.sh
│ │ │ test_settings.py
│ │ │ __init__.py
│ │ │
│ │
│
├───docs
│ README.md
│
├───src
│ │ .env__template
│ │ __init__.py
│ │
│ ├───api_provider
│ │ │───...
│ │
│ ├───app_backend
│ │ │ asgi.py
│ │ │ schema.yml
│ │ │ urls.py
│ │ │ wsgi.py
│ │ │ __init__.py
│ │ │
│ │ ├───settings
│ │ │ │ base_settings.py
│ │ │ │ secret_settings.py
│ │ │ │ __init__.py
│ │ │ │
│ │ │
│ │
│ ├───core
│ │ │───...
(note that where i put ...
there is more stuff but is out of scope for my question)
Here's what's Happening and what i've tried:
Once i launch the command the Oryx build starts with no problem and it creates the virtual environment, But even if the folder structure is the same as the one defined in the tutorial (the git repo used here ) the build does not consider the manage.py file, it doesn't understand that i'm using Django and when the Web App is starting it spits out this error Under the Application Logs Section of The Availablity and Performance Section:
2023-06-20T11:26:24.518268174Z _____
2023-06-20T11:26:24.518523677Z / _ \ __________ _________ ____
2023-06-20T11:26:24.518531977Z / /_\ \\___ / | \_ __ \_/ __ \
2023-06-20T11:26:24.518536077Z / | \/ /| | /| | \/\ ___/
2023-06-20T11:26:24.518539877Z \____|__ /_____ \____/ |__| \___ >
2023-06-20T11:26:24.518543777Z \/ \/ \/
2023-06-20T11:26:24.518547378Z A P P S E R V I C E O N L I N U X
2023-06-20T11:26:24.518550978Z
2023-06-20T11:26:24.518554578Z Documentation: http://aka.ms/webapp-linux
2023-06-20T11:26:24.518558078Z Python 3.11.3
2023-06-20T11:26:24.518561578Z Note: Any data outside '/home' is not persisted
2023-06-20T11:26:24.965278737Z Starting OpenBSD Secure Shell server: sshd.
2023-06-20T11:26:24.981641019Z App Command Line not configured, will attempt auto-detect
2023-06-20T11:26:25.036729030Z Starting periodic command scheduler: cron.
2023-06-20T11:26:25.037062334Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite
2023-06-20T11:26:25.046293736Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2023-06-20T11:26:25.048405359Z Build Operation ID: a15eed5f453186b6
2023-06-20T11:26:25.049365970Z Oryx Version: 0.2.20230512.3, Commit: a81ce1fa16b6e03d37f79d3ba5e99cf09b28e4ef, ReleaseTagName: 20230512.3
2023-06-20T11:26:25.049408271Z Output is compressed. Extracting it...
2023-06-20T11:26:25.050548183Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8db717e7578d353'...
2023-06-20T11:26:29.111384031Z App path is set to '/tmp/8db717e7578d353'
2023-06-20T11:26:29.244752368Z Detected an app based on Flask
2023-06-20T11:26:29.244785668Z Generating `gunicorn` command for 'wsgi:app'
2023-06-20T11:26:29.297725262Z Writing output script to '/opt/startup/startup.sh'
2023-06-20T11:26:29.634876261Z Using packages from virtual environment antenv located at /tmp/8db717e7578d353/antenv.
2023-06-20T11:26:29.634924661Z Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages'
2023-06-20T11:26:30.195794567Z [2023-06-20 11:26:30 +0000] [69] [INFO] Starting gunicorn 20.1.0
2023-06-20T11:26:30.206099880Z [2023-06-20 11:26:30 +0000] [69] [INFO] Listening at: http://0.0.0.0:8000 (69)
2023-06-20T11:26:30.206163281Z [2023-06-20 11:26:30 +0000] [69] [INFO] Using worker: sync
2023-06-20T11:26:30.214556273Z [2023-06-20 11:26:30 +0000] [72] [INFO] Booting worker with pid: 72
2023-06-20T11:26:32.106337436Z [2023-06-20 11:26:32 +0000] [72] [ERROR] Exception in worker process
2023-06-20T11:26:32.106380837Z Traceback (most recent call last):
2023-06-20T11:26:32.106387837Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2023-06-20T11:26:32.106406937Z worker.init_process()
2023-06-20T11:26:32.106412037Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/gunicorn/workers/base.py", line 134, in init_process
2023-06-20T11:26:32.106416637Z self.load_wsgi()
2023-06-20T11:26:32.106420737Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2023-06-20T11:26:32.106425037Z self.wsgi = self.app.wsgi()
2023-06-20T11:26:32.106429037Z ^^^^^^^^^^^^^^^
2023-06-20T11:26:32.106433137Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/gunicorn/app/base.py", line 67, in wsgi
2023-06-20T11:26:32.106437237Z self.callable = self.load()
2023-06-20T11:26:32.106441237Z ^^^^^^^^^^^
2023-06-20T11:26:32.106445337Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2023-06-20T11:26:32.106449537Z return self.load_wsgiapp()
2023-06-20T11:26:32.106453537Z ^^^^^^^^^^^^^^^^^^^
2023-06-20T11:26:32.106457538Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2023-06-20T11:26:32.106461838Z return util.import_app(self.app_uri)
2023-06-20T11:26:32.106465938Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-06-20T11:26:32.106469938Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/gunicorn/util.py", line 359, in import_app
2023-06-20T11:26:32.106474238Z mod = importlib.import_module(module)
2023-06-20T11:26:32.106478238Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-06-20T11:26:32.106482338Z File "/opt/python/3.11.3/lib/python3.11/importlib/__init__.py", line 126, in import_module
2023-06-20T11:26:32.106486438Z return _bootstrap._gcd_import(name[level:], package, level)
2023-06-20T11:26:32.106490538Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-06-20T11:26:32.106494538Z File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
2023-06-20T11:26:32.106499338Z File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
2023-06-20T11:26:32.106503438Z File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
2023-06-20T11:26:32.106507638Z File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
2023-06-20T11:26:32.106511838Z File "<frozen importlib._bootstrap_external>", line 940, in exec_module
2023-06-20T11:26:32.106516138Z File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2023-06-20T11:26:32.106520238Z File "/tmp/8db717e7578d353/wsgi.py", line 16, in <module>
2023-06-20T11:26:32.106524538Z application = get_wsgi_application()
2023-06-20T11:26:32.106529738Z ^^^^^^^^^^^^^^^^^^^^^^
2023-06-20T11:26:32.106539438Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2023-06-20T11:26:32.106544038Z return WSGIHandler()
2023-06-20T11:26:32.106548039Z ^^^^^^^^^^^^^
2023-06-20T11:26:32.106552139Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/django/core/handlers/wsgi.py", line 125, in __init__
2023-06-20T11:26:32.106556339Z self.load_middleware()
2023-06-20T11:26:32.106560339Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/django/core/handlers/base.py", line 61, in load_middleware
2023-06-20T11:26:32.106564639Z mw_instance = middleware(adapted_handler)
2023-06-20T11:26:32.106568739Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-06-20T11:26:32.106572739Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/whitenoise/middleware.py", line 105, in __init__
2023-06-20T11:26:32.106577039Z self.add_files(self.static_root, prefix=self.static_prefix)
2023-06-20T11:26:32.106581039Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/whitenoise/base.py", line 107, in add_files
2023-06-20T11:26:32.106585339Z self.update_files_dictionary(root, prefix)
2023-06-20T11:26:32.106589339Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/whitenoise/base.py", line 114, in update_files_dictionary
2023-06-20T11:26:32.106593539Z stat_cache = dict(scantree(root))
2023-06-20T11:26:32.106597539Z ^^^^^^^^^^^^^^^^^^^^
2023-06-20T11:26:32.106601639Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/whitenoise/base.py", line 263, in scantree
2023-06-20T11:26:32.106605839Z yield from scantree(entry.path)
2023-06-20T11:26:32.106609839Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/whitenoise/base.py", line 263, in scantree
2023-06-20T11:26:32.106614139Z yield from scantree(entry.path)
2023-06-20T11:26:32.106618739Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/whitenoise/base.py", line 263, in scantree
2023-06-20T11:26:32.106623139Z yield from scantree(entry.path)
2023-06-20T11:26:32.106627139Z [Previous line repeated 3 more times]
2023-06-20T11:26:32.106631139Z File "/tmp/8db717e7578d353/antenv/lib/python3.11/site-packages/whitenoise/base.py", line 265, in scantree
2023-06-20T11:26:32.106635339Z yield entry.path, entry.stat()
2023-06-20T11:26:32.106639440Z ^^^^^^^^^^^^
2023-06-20T11:26:32.106643540Z FileNotFoundError: [Errno 2] No such file or directory: '/etc/runit/runsvdir/default/ssh/log/supervise'
2023-06-20T11:26:32.106647840Z [2023-06-20 11:26:32 +0000] [72] [INFO] Worker exiting (pid: 72)
2023-06-20T11:26:32.304847511Z [2023-06-20 11:26:32 +0000] [69] [INFO] Shutting down: Master
2023-06-20T11:26:32.305164014Z [2023-06-20 11:26:32 +0000] [69] [INFO] Reason: Worker failed to boot.
Moreover, trying to edit the folder structure, by pretty much putting everything inside the src folder except the requirements.txt file (tried 20 deployments before understanding how to change the project strucuture) now the Oryx Build recognize correcly Django as a Framework + it creates the virtualenv from requirements.txt Corretly But it spits out this error:
2023-06-20T00:02:35.023066499Z _____
2023-06-20T00:02:35.023449302Z / _ \ __________ _________ ____
2023-06-20T00:02:35.023461502Z / /_\ \\___ / | \_ __ \_/ __ \
2023-06-20T00:02:35.023465802Z / | \/ /| | /| | \/\ ___/
2023-06-20T00:02:35.023469702Z \____|__ /_____ \____/ |__| \___ >
2023-06-20T00:02:35.023489902Z \/ \/ \/
2023-06-20T00:02:35.023493602Z A P P S E R V I C E O N L I N U X
2023-06-20T00:02:35.023497202Z
2023-06-20T00:02:35.023500502Z Documentation: http://aka.ms/webapp-linux
2023-06-20T00:02:35.023503802Z Python 3.10.11
2023-06-20T00:02:35.023506902Z Note: Any data outside '/home' is not persisted
2023-06-20T00:02:35.507874281Z Starting OpenBSD Secure Shell server: sshd.
2023-06-20T00:02:35.523480070Z App Command Line not configured, will attempt auto-detect
2023-06-20T00:02:35.579361588Z Starting periodic command scheduler: cron.
2023-06-20T00:02:35.579397888Z Launching oryx with: create-script -appPath /home/site/wwwroot -output /opt/startup/startup.sh -virtualEnvName antenv -defaultApp /opt/defaultsite
2023-06-20T00:02:35.585223622Z Found build manifest file at '/home/site/wwwroot/oryx-manifest.toml'. Deserializing it...
2023-06-20T00:02:35.587720636Z Build Operation ID: 1da29c90905489cd
2023-06-20T00:02:35.588963943Z Oryx Version: 0.2.20230512.3, Commit: a81ce1fa16b6e03d37f79d3ba5e99cf09b28e4ef, ReleaseTagName: 20230512.3
2023-06-20T00:02:35.589032843Z Output is compressed. Extracting it...
2023-06-20T00:02:35.590023049Z Extracting '/home/site/wwwroot/output.tar.gz' to directory '/tmp/8db709cab0c6362'...
2023-06-20T00:02:39.428269303Z App path is set to '/tmp/8db709cab0c6362'
2023-06-20T00:02:39.429343909Z Detected an app based on Django
2023-06-20T00:02:39.429361409Z Generating `gunicorn` command for 'app_backend.wsgi'
2023-06-20T00:02:39.518780718Z Writing output script to '/opt/startup/startup.sh'
2023-06-20T00:02:39.610501941Z Using packages from virtual environment antenv located at /tmp/8db709cab0c6362/antenv.
2023-06-20T00:02:39.610820242Z Updated PYTHONPATH to '/opt/startup/app_logs:/tmp/8db709cab0c6362/antenv/lib/python3.10/site-packages'
2023-06-20T00:02:39.884722002Z [2023-06-20 00:02:39 +0000] [68] [INFO] Starting gunicorn 20.1.0
2023-06-20T00:02:39.895451363Z [2023-06-20 00:02:39 +0000] [68] [INFO] Listening at: http://0.0.0.0:8000 (68)
2023-06-20T00:02:39.895478463Z [2023-06-20 00:02:39 +0000] [68] [INFO] Using worker: sync
2023-06-20T00:02:39.903472809Z [2023-06-20 00:02:39 +0000] [71] [INFO] Booting worker with pid: 71
2023-06-20T00:02:39.906353825Z [2023-06-20 00:02:39 +0000] [71] [ERROR] Exception in worker process
2023-06-20T00:02:39.906417825Z Traceback (most recent call last):
2023-06-20T00:02:39.906428826Z File "/opt/python/3.10.11/lib/python3.10/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2023-06-20T00:02:39.906446126Z worker.init_process()
2023-06-20T00:02:39.906451326Z File "/opt/python/3.10.11/lib/python3.10/site-packages/gunicorn/workers/base.py", line 134, in init_process
2023-06-20T00:02:39.906455826Z self.load_wsgi()
2023-06-20T00:02:39.906459926Z File "/opt/python/3.10.11/lib/python3.10/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2023-06-20T00:02:39.906464226Z self.wsgi = self.app.wsgi()
2023-06-20T00:02:39.906468126Z File "/opt/python/3.10.11/lib/python3.10/site-packages/gunicorn/app/base.py", line 67, in wsgi
2023-06-20T00:02:39.906472326Z self.callable = self.load()
2023-06-20T00:02:39.906476326Z File "/opt/python/3.10.11/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2023-06-20T00:02:39.906480526Z return self.load_wsgiapp()
2023-06-20T00:02:39.906484426Z File "/opt/python/3.10.11/lib/python3.10/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2023-06-20T00:02:39.906488726Z return util.import_app(self.app_uri)
2023-06-20T00:02:39.906492726Z File "/opt/python/3.10.11/lib/python3.10/site-packages/gunicorn/util.py", line 359, in import_app
2023-06-20T00:02:39.906496826Z mod = importlib.import_module(module)
2023-06-20T00:02:39.906500826Z File "/opt/python/3.10.11/lib/python3.10/importlib/__init__.py", line 126, in import_module
2023-06-20T00:02:39.906505026Z return _bootstrap._gcd_import(name[level:], package, level)
2023-06-20T00:02:39.906509026Z File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
2023-06-20T00:02:39.906513526Z File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
2023-06-20T00:02:39.906517626Z File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
2023-06-20T00:02:39.906521826Z File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
2023-06-20T00:02:39.906526326Z File "<frozen importlib._bootstrap_external>", line 883, in exec_module
2023-06-20T00:02:39.906530826Z File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
2023-06-20T00:02:39.906535026Z File "/tmp/8db709cab0c6362/app_backend/wsgi.py", line 12, in <module>
2023-06-20T00:02:39.906539426Z from django.core.wsgi import get_wsgi_application
2023-06-20T00:02:39.906543326Z ModuleNotFoundError: No module named 'django'
2023-06-20T00:02:39.906559026Z [2023-06-20 00:02:39 +0000] [71] [INFO] Worker exiting (pid: 71)
2023-06-20T00:02:39.967487373Z [2023-06-20 00:02:39 +0000] [68] [INFO] Shutting down: Master
2023-06-20T00:02:39.967526073Z [2023-06-20 00:02:39 +0000] [68] [INFO] Reason: Worker failed to boot.
UPDATE: it seems that the problem is related to whitenoise package plus the fact that Gunicorn is tested up until python 3.9, it seems that is a problem related to whitenoise + python 3.11 + Gunicorn 20.1.0 but still i'm lost on how this error is manifested on Debian
Upvotes: 0
Views: 1040
Reputation: 8694
Modify the setting ENABLE_ORYX_BUILD=true
in the App Service=>Settings=>configuration.
Try by removing DISABLE_COLLECTSTATIC setting in the configuration.
wsgi.py
file is correctly referenced in the script generated.-If still issue doesn't get fixed, try alternative ways to deploy:
1. py -m venv myworld
2. myworld\Scripts\activate.bat
3. az webapp deploy --resource-group <resource_group_name> --name <web_app_name> --src-path <project_folder>.zip
Upvotes: 0