inventree / InvenTree

Open Source Inventory Management System
https://docs.inventree.org
MIT License
4.39k stars 793 forks source link

502 Bad Gateway after update 0.12.8 -> 0.13.0 #6156

Closed JustusRijke closed 9 months ago

JustusRijke commented 11 months ago

Deployment Method

Describe the problem*

After performing an update to 0.13, using sudo apt install --only-upgrade inventree, InvenTree no longer works (website returns "502 Bad Gateway"). The upgrade seems to skip running inv update. When manually executing inv update and rebooting the system, the problem is solved.

Performed on a system running Debian 11 with InvenTree 0.12 installed using the installation script. IPv6 is disabled in /etc/sysctl.conf. /etc/nginx/sites-enabled/inventree.conf is unchanged (default content).

First mentioned in #4134

Steps to Reproduce

Perform update

Relevant log output

sudo apt install --only-upgrade inventree returns:

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages will be upgraded:
  inventree
1 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
Need to get 0 B/117 MB of archives.
After this operation, 32.5 MB of additional disk space will be used.
Reading changelogs... Done
(Reading database ... 73097 files and directories currently installed.)
Preparing to unpack .../inventree_0.13.0-1702638825.301afaa9.focal_amd64.deb ...
Unpacking inventree (0.13.0-1702638825.301afaa9.focal) over (0.12.8-1698964278.a7487ff8.focal) ...
Setting up inventree (0.13.0-1702638825.301afaa9.focal) ...
# Setting base environment variables
# Using existing config file: /etc/inventree/config.yaml

[notice] A new release of pip is available: 23.3.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip
# Collected environment variables:
#    INVENTREE_MEDIA_ROOT=/opt/inventree/data/media
#    INVENTREE_STATIC_ROOT=/opt/inventree/data/static
#    INVENTREE_BACKUP_DIR=/opt/inventree/data/backup
#    INVENTREE_PLUGINS_ENABLED=true
#    INVENTREE_PLUGIN_FILE=/etc/inventree/plugins.txt
#    INVENTREE_SECRET_KEY_FILE=/etc/inventree/secret_key.txt
#    INVENTREE_DB_ENGINE=postgresql
#    INVENTREE_DB_NAME=inventree
#    INVENTREE_DB_USER=inventree
#    INVENTREE_DB_HOST=localhost
#    INVENTREE_DB_PORT=5432
# Getting the IP address of the server via web service
IP address is xxx.xxx.xxx.xxx
# Setting up python environment
Requirement already satisfied: invoke in ./env/lib/python3.9/site-packages (2.1.3)
Requirement already satisfied: wheel in ./env/lib/python3.9/site-packages (0.40.0)

[notice] A new release of pip is available: 23.3.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip
# Stopping nginx
# Setting up nginx to /etc/nginx/sites-enabled/inventree.conf
# Starting nginx
# (Re)creating init scripts
Nothing to do.
Nothing to do.
# Enabling InvenTree on boot
# Admin data already exists - skipping
# Stopping InvenTree
# Updating InvenTree
Requirement already satisfied: wheel in ./env/lib/python3.9/site-packages (0.40.0)

[notice] A new release of pip is available: 23.3.1 -> 23.3.2
[notice] To update, run: pip install --upgrade pip
No idea what '--no-frontend' is!
# Set permissions for data dir and media: /opt/inventree/data
# Starting InvenTree
####################################################################################
This InvenTree install uses nginx, the settings for the webserver can be found in
/etc/nginx/sites-enabled/inventree.conf
Try opening InvenTree with either
http://localhost/ or http://xxx.xxx.xxx.xxx/

curl http://localhost returns:

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.18.0</center>
</body>
</html>
JustusRijke commented 10 months ago

@SparkeyinVA The problem you have is not the same as I describe in this ticket, which makes the discussion difficult to follow. Please create a new issue, move your posts to the issue (and remove them here) and let's continue the discussion there.

SparkeyinVA commented 10 months ago

@JustusRijke I have moved the commants.

SchrodingersGat commented 10 months ago

From your posted logs, the "smoking gun" is this line:

No idea what '--no-frontend' is!

The installer script seems to be running with the legacy --no-frontend tag, which is causing the invoke update task to fail.

@matmair I cannot find the --no-frontend command anywhere in the current installer, but if they are running the old installer, perhaps that is "polluted" with the --no-frontend tag?

matmair commented 10 months ago

Could be an old installer. Downloading the installer again should fix that

Sudura commented 10 months ago

manually executing inventree run invoke update and rebooting the system hasn't worked in my case

SchrodingersGat commented 10 months ago

@Sudura what was the output of the command

Sudura commented 10 months ago

During the first run it installed a bunch of packages, but i have no log from this run Now: Installing required python packages from 'requirements.txt' Requirement already satisfied: pip in ./env/lib/python3.9/site-packages (23.3.2) Requirement already satisfied: setuptools in ./env/lib/python3.9/site-packages (69.0.3) Requirement already satisfied: asgiref==3.7.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 7)) (3.7.2) Requirement already satisfied: async-timeout==4.0.3 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 9)) (4.0.3) Requirement already satisfied: attrs==23.1.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 11)) (23.1.0) Requirement already satisfied: babel==2.13.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 15)) (2.13.1) Requirement already satisfied: bleach==6.1.0 in ./env/lib/python3.9/site-packages (from bleach[css]==6.1.0->-r requirements.txt (line 17)) (6.1.0) Requirement already satisfied: brotli==1.1.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 19)) (1.1.0) Requirement already satisfied: certifi==2023.7.22 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 21)) (2023.7.22) Requirement already satisfied: cffi==1.16.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 25)) (1.16.0) Requirement already satisfied: charset-normalizer==3.3.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 29)) (3.3.2) Requirement already satisfied: coreapi==2.3.3 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 31)) (2.3.3) Requirement already satisfied: coreschema==0.0.4 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 33)) (0.0.4) Requirement already satisfied: cryptography==41.0.6 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 35)) (41.0.6) Requirement already satisfied: cssselect2==0.7.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 40)) (0.7.0) Requirement already satisfied: defusedxml==0.7.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 42)) (0.7.1) Requirement already satisfied: diff-match-patch==20230430 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 46)) (20230430) Requirement already satisfied: dj-rest-auth==5.0.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 48)) (5.0.1) Requirement already satisfied: django==3.2.23 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 50)) (3.2.23) Requirement already satisfied: django-allauth==0.54.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 84)) (0.54.0) Requirement already satisfied: django-allauth-2fa==0.11.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 88)) (0.11.1) Requirement already satisfied: django-cleanup==8.0.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 90)) (8.0.0) Requirement already satisfied: django-cors-headers==4.3.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 92)) (4.3.0) Requirement already satisfied: django-crispy-forms==1.14.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 94)) (1.14.0) Requirement already satisfied: django-dbbackup==4.0.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 96)) (4.0.2) Requirement already satisfied: django-error-report-2==0.4.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 98)) (0.4.2) Requirement already satisfied: django-filter==23.3 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 100)) (23.3) Requirement already satisfied: django-flags==5.0.13 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 102)) (5.0.13) Requirement already satisfied: django-formtools==2.4.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 104)) (2.4.1) Requirement already satisfied: django-ical==1.9.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 106)) (1.9.2) Requirement already satisfied: django-import-export==3.3.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 108)) (3.3.1) Requirement already satisfied: django-js-asset==2.1.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 110)) (2.1.0) Requirement already satisfied: django-maintenance-mode==0.21.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 112)) (0.21.0) Requirement already satisfied: django-markdownify==0.9.3 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 114)) (0.9.3) Requirement already satisfied: django-money==3.2.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 116)) (3.2.0) Requirement already satisfied: django-mptt==0.11.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 118)) (0.11.0) Requirement already satisfied: django-otp==1.2.4 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 120)) (1.2.4) Requirement already satisfied: django-picklefield==3.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 122)) (3.1) Requirement already satisfied: django-q-sentry==0.1.6 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 124)) (0.1.6) Requirement already satisfied: django-q2==1.6.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 126)) (1.6.1) Requirement already satisfied: django-recurrence==1.11.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 128)) (1.11.1) Requirement already satisfied: django-redis==5.4.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 130)) (5.4.0) Requirement already satisfied: django-sesame==3.2.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 132)) (3.2.1) Requirement already satisfied: django-sql-utils==0.7.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 134)) (0.7.0) Requirement already satisfied: django-sslserver==0.22 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 136)) (0.22) Requirement already satisfied: django-stdimage==6.0.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 138)) (6.0.2) Requirement already satisfied: django-taggit==4.0.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 140)) (4.0.0) Requirement already satisfied: django-user-sessions==2.0.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 142)) (2.0.0) Requirement already satisfied: django-weasyprint==2.2.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 144)) (2.2.1) Requirement already satisfied: django-xforwardedfor-middleware==2.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 146)) (2.0) Requirement already satisfied: djangorestframework==3.14.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 148)) (3.14.0) Requirement already satisfied: djangorestframework-simplejwt==5.3.0 in ./env/lib/python3.9/site-packages (from djangorestframework-simplejwt[crypto]==5.3.0->-r requirements.txt (line 154)) (5.3.0) Requirement already satisfied: drf-spectacular==0.26.5 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 156)) (0.26.5) Requirement already satisfied: dulwich==0.21.6 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 158)) (0.21.6) Requirement already satisfied: et-xmlfile==1.1.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 160)) (1.1.0) Requirement already satisfied: feedparser==6.0.10 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 162)) (6.0.10) Requirement already satisfied: fonttools==4.44.0 in ./env/lib/python3.9/site-packages (from fonttools[woff]==4.44.0->-r requirements.txt (line 164)) (4.44.0) Requirement already satisfied: gunicorn==21.2.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 166)) (21.2.0) Requirement already satisfied: html5lib==1.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 168)) (1.1) Requirement already satisfied: icalendar==5.0.11 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 170)) (5.0.11) Requirement already satisfied: idna==3.4 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 172)) (3.4) Requirement already satisfied: importlib-metadata==6.8.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 174)) (6.8.0) Requirement already satisfied: inflection==0.5.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 178)) (0.5.1) Requirement already satisfied: itypes==1.2.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 180)) (1.2.0) Requirement already satisfied: jinja2==3.1.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 182)) (3.1.2) Requirement already satisfied: jsonschema==4.19.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 184)) (4.19.2) Requirement already satisfied: jsonschema-specifications==2023.7.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 186)) (2023.7.1) Requirement already satisfied: markdown==3.5.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 188)) (3.5.1) Requirement already satisfied: markuppy==1.14 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 190)) (1.14) Requirement already satisfied: markupsafe==2.1.3 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 192)) (2.1.3) Requirement already satisfied: oauthlib==3.2.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 194)) (3.2.2) Requirement already satisfied: odfpy==1.4.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 196)) (1.4.1) Requirement already satisfied: openpyxl==3.1.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 198)) (3.1.2) Requirement already satisfied: packaging==23.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 200)) (23.2) Requirement already satisfied: pdf2image==1.16.3 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 202)) (1.16.3) Requirement already satisfied: pillow==10.1.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 204)) (10.1.0) Requirement already satisfied: pint==0.21 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 212)) (0.21) Requirement already satisfied: py-moneyed==3.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 214)) (3.0) Requirement already satisfied: pycparser==2.21 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 216)) (2.21) Requirement already satisfied: pydyf==0.8.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 218)) (0.8.0) Requirement already satisfied: pyjwt==2.8.0 in ./env/lib/python3.9/site-packages (from pyjwt[crypto]==2.8.0->-r requirements.txt (line 220)) (2.8.0) Requirement already satisfied: pyphen==0.14.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 224)) (0.14.0) Requirement already satisfied: pypng==0.20220715.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 226)) (0.20220715.0) Requirement already satisfied: python-barcode==0.15.1 in ./env/lib/python3.9/site-packages (from python-barcode[images]==0.15.1->-r requirements.txt (line 228)) (0.15.1) Requirement already satisfied: python-dateutil==2.8.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 230)) (2.8.2) Requirement already satisfied: python-dotenv==1.0.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 234)) (1.0.0) Requirement already satisfied: python-fsutil==0.12.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 236)) (0.12.0) Requirement already satisfied: python3-openid==3.2.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 238)) (3.2.0) Requirement already satisfied: pytz==2023.3.post1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 240)) (2023.3.post1) Requirement already satisfied: pyyaml==6.0.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 246)) (6.0.1) Requirement already satisfied: qrcode==7.4.2 in ./env/lib/python3.9/site-packages (from qrcode[pil]==7.4.2->-r requirements.txt (line 251)) (7.4.2) Requirement already satisfied: rapidfuzz==0.7.6 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 255)) (0.7.6) Requirement already satisfied: redis==5.0.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 257)) (5.0.1) Requirement already satisfied: referencing==0.30.2 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 259)) (0.30.2) Requirement already satisfied: regex==2023.10.3 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 263)) (2023.10.3) Requirement already satisfied: requests==2.31.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 265)) (2.31.0) Requirement already satisfied: requests-oauthlib==1.3.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 270)) (1.3.1) Requirement already satisfied: rpds-py==0.12.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 272)) (0.12.0) Requirement already satisfied: sentry-sdk==1.34.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 276)) (1.34.0) Requirement already satisfied: sgmllib3k==1.0.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 280)) (1.0.0) Requirement already satisfied: six==1.16.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 282)) (1.16.0) Requirement already satisfied: sqlparse==0.4.4 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 287)) (0.4.4) Requirement already satisfied: tablib==3.5.0 in ./env/lib/python3.9/site-packages (from tablib[html,ods,xls,xlsx,yaml]==3.5.0->-r requirements.txt (line 291)) (3.5.0) Requirement already satisfied: tinycss2==1.2.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 295)) (1.2.1) Requirement already satisfied: typing-extensions==4.8.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 300)) (4.8.0) Requirement already satisfied: uritemplate==4.1.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 305)) (4.1.1) Requirement already satisfied: urllib3==2.0.7 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 309)) (2.0.7) Requirement already satisfied: weasyprint==60.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 314)) (60.1) Requirement already satisfied: webencodings==0.5.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 318)) (0.5.1) Requirement already satisfied: xlrd==2.0.1 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 324)) (2.0.1) Requirement already satisfied: xlwt==1.3.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 326)) (1.3.0) Requirement already satisfied: zipp==3.16.0 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 328)) (3.16.0) Requirement already satisfied: zopfli==0.2.3 in ./env/lib/python3.9/site-packages (from -r requirements.txt (line 330)) (0.2.3) Requirement already satisfied: setuptools in ./env/lib/python3.9/site-packages (from django-money==3.2.0->-r requirements.txt (line 116)) (69.0.3) Backing up InvenTree database... Python version 3.9.5 - /opt/inventree/env/bin/python3 load version from file Traceback (most recent call last): File "/opt/inventree/InvenTree/manage.py", line 23, in <module> execute_from_command_line(sys.argv) File "/opt/inventree/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/opt/inventree/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 363, in execute settings.INSTALLED_APPS File "/opt/inventree/env/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__ self._setup(name) File "/opt/inventree/env/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup self._wrapped = Settings(settings_module) File "/opt/inventree/env/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 855, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/opt/inventree/InvenTree/InvenTree/settings.py", line 129, in <module> STATIC_ROOT = config.get_static_dir() File "/opt/inventree/InvenTree/InvenTree/config.py", line 237, in get_static_dir raise FileNotFoundError('INVENTREE_STATIC_ROOT not specified') FileNotFoundError: INVENTREE_STATIC_ROOT not specified

SparkeyinVA commented 10 months ago

@Sudura I could finally get around this issue where "INVENTREE_STATIC_ROOT" was not found.

But I noticed a note in the log which stated that config.yaml was not found, so one was created at /opt/inventree/InvenTree/config.yaml I then copied the config.yaml from /etc/inventree/ to /opt/inventree/InvenTree/. I then ran inv update again, and it found the config file and updated and backed up the database as expected.

cd /opt/inventree
source ./env/bin/activate
inv update
sudo reboot now

It looks like the single line installer is looking for config.yaml at /etc/inventree/ the inv update is looking for config.yaml at /opt/inventree/InvenTree/

After the restart it may take several minutes for inventree to come in line so at first you will see a 504 error but then inventree will start.

I hope this helps.

mittkkoo commented 10 months ago

Also got the 502 error after update from 0.12.8 to 0.13.0 with sudo apt install --only-upgrade inventree.

Additional inventree run invoke update and reboot worked for me.

mittkkoo commented 10 months ago

Well, after updating to 0.13.0-1705069754.213a6331.focal amd64 I can't any more get rid of the 502 error. inventree run invoke update gives at the end:

Backing up InvenTree database...
Python version 3.9.5 - /opt/inventree/env/bin/python3
load version from file
Traceback (most recent call last):
  File "/opt/inventree/InvenTree/manage.py", line 23, in <module>
    main()
  File "/opt/inventree/InvenTree/manage.py", line 19, in main
    execute_from_command_line(sys.argv)
  File "/opt/inventree/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/opt/inventree/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute
    django.setup()
  File "/opt/inventree/env/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/opt/inventree/env/lib/python3.9/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/opt/inventree/env/lib/python3.9/site-packages/allauth/account/apps.py", line 15, in ready
    raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: allauth.account.middleware.AccountMiddleware must be added to settings.MIDDLEWARE

allauth 0.59 django 3.2.23

Solution: I had to add 'allauth.account.middleware.AccountMiddleware' in MIDDLEWARE in both config.yaml files I found.

SchrodingersGat commented 10 months ago

@mittkkoo can you please revert the changes you made to config.yaml and try:

inventree run invoke update --skip-backup

(and report back if that runs without error)

It may be that update to allauth means that we need to carefully consider the update operation

eimparas commented 10 months ago

I have the same issue after updrade .

my version is :

INVENTREE_COMMIT_HASH='e81349e7'
INVENTREE_COMMIT_DATE='2024-01-21T13:41:00Z'
INVENTREE_PKG_INSTALLER='PKG'
INVENTREE_PKG_BRANCH='stable'
INVENTREE_PKG_TARGET='debian:11'
NODE_ID='C_kwDOBR6lPdoAKGU4MTM0OWU3MGUzZjlmYjk3ZGUzNmZhZmMxODU5ZDk2NGU5OTNhNGY'
SIGNATURE='-----BEGIN PGP SIGNATURE-----
sdfsdafsdjflksadjhfkljasdhflkasjdhflkasdjhflaks
-----END PGP SIGNATURE-----'

when i run inventree run invoke update i get


Traceback (most recent call last):
  File "/opt/inventree/env/bin/invoke", line 8, in <module>
    sys.exit(program.run())
  File "/opt/inventree/env/lib/python3.9/site-packages/invoke/program.py", line 373, in run
    self.parse_collection()
  File "/opt/inventree/env/lib/python3.9/site-packages/invoke/program.py", line 465, in parse_collection
    self.load_collection()
  File "/opt/inventree/env/lib/python3.9/site-packages/invoke/program.py", line 699, in load_collection
    module, parent = loader.load(coll_name)
  File "/opt/inventree/env/lib/python3.9/site-packages/invoke/loader.py", line 76, in load
    module = imp.load_module(name, fd, path, desc)
  File "/usr/lib/python3.9/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/usr/lib/python3.9/imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 711, in _load
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/opt/inventree/tasks.py", line 387, in <module>
    def update(c, skip_backup=False, frontend: bool = False, no_frontend: bool = False):
  File "/opt/inventree/env/lib/python3.9/site-packages/invoke/tasks.py", line 357, in inner
  File "/opt/inventree/env/lib/python3.9/site-packages/invoke/tasks.py", line 76, in __init__
  File "/opt/inventree/env/lib/python3.9/site-packages/invoke/tasks.py", line 167, in fill_implicit_positionals
  File "/opt/inventree/env/lib/python3.9/site-packages/invoke/tasks.py", line 153, in argspec
    spec = inspect.getargspec(func)
  File "/usr/lib/python3.9/inspect.py", line 1122, in getargspec
    raise ValueError("Function has keyword-only parameters or annotations"
ValueError: Function has keyword-only parameters or annotations, use inspect.signature() API which can support them

all i get after a curl

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.18.0</center>
</body>
</html>

Nothing of the beforementioned solutions worked

SchrodingersGat commented 10 months ago

@eimparas looks like your invoke version is too old (needs to be 2.0.0 or newer):

https://docs.inventree.org/en/latest/faq/#invoke-version

image

eimparas commented 10 months ago

@SchrodingersGat
i did pip install -U invoke and i got upgraded to Invoke 2.2.0 , then performed a invoke update but still no dice .

curl 127.0.0.1 :

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.18.0</center>
</body>
</html>
eimparas commented 10 months ago

I managed to fix it by deleting data/media/maintenance_mode_state.txt and data/static/maintenance_mode_state.txt, and runninginvoke update again. Both the mentioned files were empty.

SchrodingersGat commented 10 months ago

@eimparas thanks for providing this information - those files should not be empty, so we will have to look into that

mittkkoo commented 9 months ago

@mittkkoo can you please revert the changes you made to config.yaml and try:

inventree run invoke update --skip-backup

(and report back if that runs without error)

It may be that update to allauth means that we need to carefully consider the update operation

I currently have the same problem with updating to 0.14.1 This is when I run from inside the environment: (env) root@xxx:/opt/inventree# inventree run invoke update . Beforehand I updated Invoke to 2.2.0 (was 1.3.0).

Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 69.1.1
    Uninstalling setuptools-69.1.1:
      Successfully uninstalled setuptools-69.1.1
Successfully installed setuptools-69.1.0
Installing plugin packages from '/etc/inventree/plugins.txt'
Backing up InvenTree database...
Python version 3.10.13 - /opt/inventree/env/bin/python3
load version from file
Python version 3.10.13 - /opt/inventree/env/bin/python3
load version from file
Traceback (most recent call last):
  File "/opt/inventree/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 237, in fetch_command
    app_name = commands[subcommand]
KeyError: 'dbbackup'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/inventree/InvenTree/manage.py", line 24, in <module>
    main()
  File "/opt/inventree/InvenTree/manage.py", line 20, in main
    execute_from_command_line(sys.argv)
  File "/opt/inventree/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/opt/inventree/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/inventree/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 244, in fetch_command
    settings.INSTALLED_APPS
  File "/opt/inventree/env/lib/python3.10/site-packages/django/conf/__init__.py", line 82, in __getattr__
    self._setup(name)
  File "/opt/inventree/env/lib/python3.10/site-packages/django/conf/__init__.py", line 69, in _setup
    self._wrapped = Settings(settings_module)
  File "/opt/inventree/env/lib/python3.10/site-packages/django/conf/__init__.py", line 170, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/opt/inventree/InvenTree/InvenTree/settings.py", line 565, in <module>
    from django.db.backends.postgresql.psycopg_any import IsolationLevel
ModuleNotFoundError: No module named 'django.db.backends.postgresql.psycopg_any'
SchrodingersGat commented 9 months ago

Have you tried running the update command with the --skip-backup flag?

mittkkoo commented 9 months ago

Yes, I tried. The problem is python 3.10.13. As soon as I downgrade to 3.9.5 in the virtual environment, the update will succeed. After the update I could change back to 3.10, but this is an ugly workaround.

SchrodingersGat commented 9 months ago

Have you manually upgraded your python version and venv?

diankov commented 8 months ago

I created a new env with python3.10 -m venv env

SchrodingersGat commented 8 months ago

If you are using postgres, you will need to install the required postgres dependencies into your new venv