meeb / tubesync

Syncs YouTube channels and playlists to a locally hosted media server
GNU Affero General Public License v3.0
1.84k stars 119 forks source link

gunicorn on native installation #473

Closed lgwapnitsky closed 1 month ago

lgwapnitsky commented 6 months ago

I'm trying to run the command as the other user did, but am still running into the same issue. The reason I'm running on native is that I"ve had some issues running Docker in LXC on Proxmox, and am trying to use minimal disk resources.

Thank you

          1. I used the command of the following type: gunicorn --chdir/Home/XXX/Tubesync/Tubesync/-B 192.168.10.2:8001 WSGI &
  1. Edited in the settings.py file the line ALLOWED_HOSTS by adding its IP address.
  2. Launched the command ./manage.py process_tasks & I did not use the reverse proxy. Everything worked on the i386 system. Please close the question.

Originally posted by @HeadMountainRain in https://github.com/meeb/tubesync/issues/304#issuecomment-1383180079

lgwapnitsky commented 6 months ago

error output:

(ts-venv) tubesync@tubesync:/opt/tubesync/tubesync/tubesync$ gunicorn --chdir  /opt/tubesync/tubesync/tubesync/ -b 127.0.0.1 wsgi
[2024-02-24 21:20:50 +0000] [10674] [INFO] Starting gunicorn 21.2.0
[2024-02-24 21:20:50 +0000] [10674] [INFO] Listening at: http://127.0.0.1:8000 (10674)
[2024-02-24 21:20:50 +0000] [10674] [INFO] Using worker: sync
[2024-02-24 21:20:50 +0000] [10675] [INFO] Booting worker with pid: 10675
[2024-02-24 21:20:51 +0000] [10675] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
    worker.init_process()
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/gunicorn/workers/base.py", line 134, in init_process
    self.load_wsgi()
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
    self.wsgi = self.app.wsgi()
                ^^^^^^^^^^^^^^^
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
                    ^^^^^^^^^^^
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
    return self.load_wsgiapp()
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
    return util.import_app(self.app_uri)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/gunicorn/util.py", line 371, in import_app
    mod = importlib.import_module(module)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/tubesync/tubesync/tubesync/wsgi.py", line 8, in <module>
    _application = get_wsgi_application()
                   ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
                      ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/tubesync/ts-venv/lib/python3.11/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1128, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1142, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tubesync'
[2024-02-24 21:20:51 +0000] [10675] [INFO] Worker exiting (pid: 10675)
[2024-02-24 21:20:51 +0000] [10674] [ERROR] Worker (pid:10675) exited with code 3
[2024-02-24 21:20:51 +0000] [10674] [ERROR] Shutting down: Master
[2024-02-24 21:20:51 +0000] [10674] [ERROR] Reason: Worker failed to boot.
meeb commented 6 months ago

This is a path issue, the 'tubesync' Django app isn't importable from the path as used by gunicorn.

Just to mention, you're really not going to save any resources here at all by running it manually vs the container. The only thing the container runs in addition to what you're manually running here is nginx (in 'light' mode which uses a few mb of ram) and the very lightweight S6 init system. It really is easier to run in the container. By the time you've built all the dependencies to run tubesync your base install will be larger than the container anyway, Python is pretty sprawling with libraries.

If you persist with attempting to run this manually you'll need to fix the path for gunicorn. Internally tubesync runs this command:

gunicorn -c /path/to/tubesync/gunicorn.py --capture-output tubesync.wsgi:application

With the gunicorn config:

https://github.com/meeb/tubesync/blob/main/tubesync/tubesync/gunicorn.py

meeb commented 1 month ago

I'll close this for now but feel free to comment if you still have issues setting this up.