YunoHost-Apps / ihatemoney_ynh

Ihatemoney package for YunoHost
Other
9 stars 6 forks source link

502 Bad Gateway - nginx #52

Closed schuhwerk closed 1 year ago

schuhwerk commented 1 year ago

Hi 🖖Thank you for this great product :D I hope I'm at the right place here. Thanks for your time in advance!

Bad Gateway issue

I installed ihatemoney on a fresh hetzner yunohost instance (with these instructions) a few weeks ago and everything worked perfectly out of the box. A week later (without touching anything) my ihatemoney instance showed 502 Bad Gateway nginx. The other apps did/do not have any problems.

Context

Steps to reproduce

I tried lots of things (see below). So I set up a fresh (untouched) yunohost instance and only installed ihatemoney (via web ui). This also gives me an empty page with the "Bad Gateway" message. Am I alone with that?

Expected behavior

The page should show the ihatemoney ui like here.

Things I (also) tried/checked (sadly without success)

Looks like an issue with nginx, so we restart the required services (good old: turn it off and on).

Didn't help. So look at logs.

https://examle.com/yunohost/admin/#/services/ihatemoney (journalctl)

Jan 15 17:52:34 gunicorn[1370]: [2023-01-15 17:52:34 +0000] [1370] [CRITICAL] WORKER TIMEOUT (pid:2315)
Jan 15 17:52:34 gunicorn[5527]: [2023-01-15 17:52:34 +0000] [5527] [INFO] Booting worker with pid: 5527
Jan 15 17:52:35 gunicorn[5527]: INFO  [alembic.runtime.migration] Context impl MySQLImpl.
Jan 15 17:52:35 gunicorn[5527]: INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

cat /var/log/daemon.log

Jan 15 18:56:09 yuno gunicorn[1370]: [2023-01-15 18:56:09 +0000] [1370] [CRITICAL] WORKER TIMEOUT (pid:5391)
Jan 15 18:56:09 yuno mariadbd[1128]: 2023-01-15 18:56:09 42 [Warning] Aborted connection 42 to db: 'ihatemoney' user: 'ihatemoney' host: 'localhost' (Got an error reading communication packets)
Jan 15 18:56:09 yuno gunicorn[7579]: [2023-01-15 18:56:09 +0000] [7579] [INFO] Booting worker with pid: 7579
Jan 15 18:56:09 yuno gunicorn[7579]: INFO  [alembic.runtime.migration] Context impl MySQLImpl.
Jan 15 18:56:09 yuno gunicorn[7579]: INFO  [alembic.runtime.migration] Will assume non-transactional DDL.

https://yuno.example.com/yunohost/admin/#/services/nginx /var/log/nginx/yuno.example.com-error.log

2023/01/14 19:49:11 [error] 12319#12319: *24 directory index of "/var/www/ihatemoney/venv/lib/python3.9/site-packages/ihatemoney/static/" is forbidden, client: 62.216.199.26, server: yuno.example.com, request: "GET /ihatemoney/static/ HTTP/2.0", host: "yuno.example.com"
2023/01/14 19:49:35 [error] 12319#12319: *24 upstream prematurely closed connection while reading response header from upstream, client: 62.216.199.26, server: yuno.example.com, request: "GET /ihatemoney/ HTTP/2.0", upstream: "http://unix:/tmp/budget.gunicorn_ihatemoney.sock:/ihatemoney/", host: "yuno.example.com"
2023/01/14 19:51:01 [error] 12648#12648: *1 upstream prematurely closed connection while reading response header from upstream, client: 62.216.199.26, server: yuno.example.com, request: "GET /ihatemoney/ HTTP/2.0", upstream: "http://unix:/tmp/budget.gunicorn_ihatemoney.sock:/ihatemoney/", host: "yuno.example.com"
2023/01/14 19:57:57 [error] 13077#13077: *1 upstream prematurely closed connection while reading response header from upstream, client: 62.216.199.26, server: yuno.example.com, request: "GET /ihatemoney/ HTTP/2.0", upstream: "http://unix:/tmp/budget.gunicorn_ihatemoney.sock:/ihatemoney/", host: "yuno.example.com"
2023/01/14 20:04:03 [crit] 13077#13077: *16 connect() to unix:/tmp/budget.gunicorn_ihatemoney.sock failed (2: No such file or directory) while connecting to upstream, client: 62.216.199.26, server: yuno.example.com, request: "GET /ihatemoney/ HTTP/2.0", upstream: "http://unix:/tmp/budget.gunicorn_ihatemoney.sock:/ihatemoney/", host: "yuno.example.com"

The connect() to unix:/tmp/budget.gunicorn_ihatemoney.sock failed looks bad. So I found this and thought it might have been an issue with nginx not being able to use the socket in /temp.

So I added PrivateTmp=no to

The error does not appear anymore, but my issue still remains.


The other issue that looks suspicious is [Warning] Aborted connection 42 to db: 'ihatemoney' user: 'ihatemoney' host: 'localhost' (Got an error reading communication packets) from the daemon.log.

So I checked if db access is set properly: mysql --database=ihatemoney --user=ihatemoney -p use password from cat /var/www/ihatemoney/ihatemoney.cfg

SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://ihatemoney:MYPASSWORD@localhost/ihatemoney'

Works without problems. Not sure how to check if there is an issue with sqlalchemy...


... so I thought: just use sqlite (from here) nano /var/www/ihatemoney/ihatemoney.cfg SQLALCHEMY_DATABASE_URI = 'sqlite:////var/lib/ihatemoney/ihatemoney.sqlite' create the folder and file and chmod 777 them.

source /var/www/ihatemoney/venv/bin/activate
export IHATEMONEY_SETTINGS_FILE_PATH=$PWD/ihatemoney.cfg 
ihatemoney db upgrade head

Nah, doesn't help.


So i thought: it might have been an update to the repo, which happened a week ago. I went ahead and rolled back the changes and manually installed an older version from here.

Didn't help. nginx still tells me

2023/01/15 20:33:17 [error] 3551#3551: *42 upstream prematurely closed connection while reading response header from upstream, client: 62.216.199.26, server: yuno.example.com, request: "GET /ihatemoney/ HTTP/2.0", upstream: "http://unix:/tmp/budget.gunicorn_ihatemoney.sock:/ihatemoney/", host: "yuno.example.com"

Forced upgrade (yunohost app upgrade ihatemoney --force) didn't help.


Updating yunohost to latest dev didn't help.


yuno.example.com/ihatemoney/static/favicon.ico is working

Any ideas?

schuhwerk commented 1 year ago

Lol. I just came back to my installation and its now working again. Didn't do anything since my last attempt. Maybe it was a language issue (I used German). Cheers!