go-gitea / gitea

Git with a cup of tea! Painless self-hosted all-in-one software development service, including Git hosting, code review, team collaboration, package registry and CI/CD
https://gitea.com
MIT License
43.82k stars 5.38k forks source link

Initial Config Page Shows When Container Crashes #27216

Closed TheBig-O closed 7 months ago

TheBig-O commented 11 months ago

Description

This morning, Gitea crashed and instead of showing warnings or some other screen, the initial setup screen appeared with all the settings I had as environment variables in the docker-compose.yml. Because it had the IP addresses, file paths, and passwords, I think this is not the right thing to be showing if there is an error. I would be okay with the paths and database names, but really don't want my password being available to someone if Gitea crashes again. Is there a way to disable the setup screen? Below is the relevant log information. I removed IPs and replaced with 000.00.000.000 in three spots. Thanks for your help!

2023/09/23 12:34:28 ...eb/routing/logger.go:98:func1() [I] [650f1394] router: completed GET /user/login?redirect_to=%2fgitea%2fNAME%2fDocker-Compose_Files%2fsrc%2fbranch%2fmaster%2ffilecloud-docker-compose.yml for 000.00.000.000:0, 404 Not Found in 5.9ms @ install/routes.go:120(install.installNotFound)
09/23/202312:34:33 PM
2023/09/23 12:34:33 ...eb/routing/logger.go:98:func1() [I] [650f1399] router: completed GET /NAME/Docker-Compose_Files/src/branch/master/filecloud-docker-compose.yml for 000.00.000.000:0, 404 Not Found in 0.0ms @ install/routes.go:120(install.installNotFound)
09/23/202312:34:43 PM
2023/09/23 12:34:43 ...eb/routing/logger.go:98:func1() [I] [650f13a3] router: completed GET / for 000.00.000.000:0, 200 OK in 51.3ms @ install/install.go:90(install.Install)
09/23/202312:36:09 PM
2023/09/23 12:36:09 ...eful/manager_unix.go:149:handleSignals() [W] [6506aa61] PID 15. Received SIGTERM. Shutting down...
09/23/202312:36:09 PM
Received signal 15; terminating.
09/23/202312:36:09 PM
2023/09/23 12:36:09 .../graceful/manager.go:205:doHammerTime() [W] Setting Hammer condition
09/23/202312:36:09 PM
2023/09/23 12:36:09 ...eful/server_hooks.go:46:doShutdown() [I] [6506aa61-3] PID: 15 Listener ([::]:3000) closed.
09/23/202312:36:09 PM
2023/09/23 12:36:09 cmd/web.go:271:listen() [I] [6506aa61-3] HTTP Listener: 0.0.0.0:3000 Closed
09/23/202312:36:10 PM
2023/09/23 12:36:10 .../graceful/manager.go:224:doTerminate() [W] Terminating
09/23/202312:36:10 PM
2023/09/23 12:36:10 ...eful/manager_unix.go:157:handleSignals() [W] PID: 15. Background context for manager closed - context canceled - Shutting down...
09/23/202312:36:10 PM
2023/09/23 12:36:10 cmd/web.go:139:runWeb() [I] PID: 15 Gitea Web Finished
09/23/202312:36:11 PM
Server listening on :: port 22.
09/23/202312:36:11 PM
Server listening on 0.0.0.0 port 22.

Gitea Version

1.19.3

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

2.38.5

Operating System

Debian Linux

How are you running Gitea?

Gitea is running in a Docker Container using Compose.

Database

MySQL/MariaDB

delvh commented 11 months ago

Well… the setup screen only shows when

[security]
INSTALL_LOCK = true

is not set or false in the app.ini. Normally, gitea should explicitly prevent that by setting this setting as soon as you complete the install page. The fact that this hasn't been done indicates to me that Gitea wasn't able to set it, i.e. because the file is read-only. Is the app.ini perhaps mounted read-only in your container?

In summary, normally Gitea doesn't need to be reinitialized after a crash.

delvh commented 11 months ago

Furthermore, according to your logs, it didn't even crash, the OS told it to shutdown:

2023/09/23 12:36:09 ...eful/manager_unix.go:149:handleSignals() [W] [6506aa61] PID 15. Received SIGTERM. Shutting down...
delvh commented 11 months ago

If that's the case, could you please check as well if [security].INTERNAL_TOKEN has been persisted? If no, then you might have a lot of problems.

TheBig-O commented 11 months ago

Thank you for the feed back. I had restarted the container, which is the sigterm line. Where would I check if it is persisted?

delvh commented 11 months ago

I don't know exactly where the app.ini is located in the Docker container, but I guess something like var/lib/gitea/custom/conf/app.ini or /etc/gitea/custom/conf/app.ini In the worst case:

find / -type f -name 'app.ini'

That will certainly find it, but might take a bit.

TheBig-O commented 11 months ago

I found it pretty easily. It's in the "/conf/" folder and is part of the the Volume setup for my docker-compose.yml. Each of the items you mentioned and all were set as you suggested. I'm not sure why that page popped up. The only real error I can point to is install/routes.go:120(install.installNotFound) in the log I posted before. It "Shouldn't" have shown that page, but definitely did. I'll keep an eye on it and see if I can recreate it.

wxiaoguang commented 7 months ago

Maybe you mixed "root" / "rootless" image. Their directory layouts are different.

Feel free to reopen if there are reproducible steps with latest release.