[Docs] Instructions for logrotate need attention #7328

Closed
opened 2025-11-02 07:23:03 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @lonix1 on GitHub (May 12, 2021).

  • Gitea version (or commit ref): 1.13.2
  • Git version: 2.25.1
  • Operating system: linux
  • docker
  • Database (use [x]):
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • not applicable
  • Log gist:
    n/a

Description

I want to do custom log rotation using logrotate.

Original issue: #9960
Implemented in PR: #11777
Docs: link

Docs say to send kill -USR1 to process that represents gitea container; but for that doesn't work for me. The logger continues to log to gitea.log.1 (instead of gitea.log).

Alternative is to do: docker exec gitea_container_name gitea manager logging release-and-reopen, but I get:

...s/setting/setting.go:844:NewContext() [F] Expect user 'git' but current user is: root

As I posted before, what works is this:

docker exec gitea_container_name sh -c 's6-svc -1 /etc/s6/gitea/'

When using s6 that is the proper way to signal the process. It matches the startup of the container as well, see here.

I don't understand how this works for other people. I think the docs are wrong, and the approach I used above should be used as "correct", or at least as another alternative.

Originally created by @lonix1 on GitHub (May 12, 2021). - Gitea version (or commit ref): 1.13.2 - Git version: 2.25.1 - Operating system: linux - docker - Database (use `[x]`): - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [x] not applicable - Log gist: n/a ## Description I want to do custom log rotation using logrotate. Original issue: #9960 Implemented in PR: #11777 Docs: [link](https://docs.gitea.io/en-us/logging-configuration/#using-logrotate-instead-of-built-in-log-rotation) Docs say to send `kill -USR1` to process that represents gitea container; but for that doesn't work for me. The logger continues to log to `gitea.log.1` (instead of `gitea.log`). Alternative is to do: `docker exec gitea_container_name gitea manager logging release-and-reopen`, but I get: > ...s/setting/setting.go:844:NewContext() [F] Expect user 'git' but current user is: root As I posted [before](https://github.com/go-gitea/gitea/issues/9960#issuecomment-630728397), what works is this: ````sh docker exec gitea_container_name sh -c 's6-svc -1 /etc/s6/gitea/' ```` When using s6 that is the proper way to signal the process. It matches the startup of the container as well, see [here](https://github.com/go-gitea/gitea/blob/dd81c290529eb5692b46553b2fac120820872a1c/Dockerfile#L64). I don't understand how this works for other people. I think the docs are wrong, and the approach I used above should be used as "correct", or at least as another alternative.
GiteaMirror added the type/docs label 2025-11-02 07:23:03 -06:00
Author
Owner

@zeripath commented on GitHub (May 12, 2021):

docker exec -u git gitea_container_name gitea manager logging release-and-reopen

@zeripath commented on GitHub (May 12, 2021): docker exec -u git gitea_container_name gitea manager logging release-and-reopen
Author
Owner

@lonix1 commented on GitHub (May 13, 2021):

Thanks for that. If so it should be added to that docs section, would help others.

My way is foolproof when using s6, but relying on the app to reload its logs is probably the best way, I agree with you. It's a nice feature.

@lonix1 commented on GitHub (May 13, 2021): Thanks for that. If so it should be added to that docs section, would help others. My way is foolproof when using s6, but relying on the app to reload its logs is probably the best way, I agree with you. It's a nice feature.
Author
Owner

@zeripath commented on GitHub (May 13, 2021):

Where did you find the instruction to docker exec gitea manager logging release-and-reopen? I only see gitea manager logging release-and-reopen in the docs.

@zeripath commented on GitHub (May 13, 2021): Where did you find the instruction to `docker exec gitea manager logging release-and-reopen`? I only see `gitea manager logging release-and-reopen` in the docs.
Author
Owner

@lonix1 commented on GitHub (May 13, 2021):

Exactly, I didn't - I figured that out myself, but forgot about the -u git which you gave me above. (Thanks again!)

So like I said those docs need some attention.

I think all three options are good, but your way is best. So in postrotate .. endscript, use:

  • docker exec -u git gitea_container_name sh -c 'gitea manager logging release-and-reopen' BEST
  • docker exec gitea_container_name sh -c '/bin/s6-svc -1 /etc/s6/gitea/ relies on s6 (foolproof way used in most cases, but in this case we have a built-in way which is better)
  • kill -USR1 $(docker inspect --format '{{.State.Pid}}' "$gitea_container_name") signal process directly
@lonix1 commented on GitHub (May 13, 2021): Exactly, I didn't - I figured that out myself, but forgot about the `-u git` which you gave me above. (Thanks again!) So like I said those docs need some attention. I think all three options are good, but your way is best. So in `postrotate .. endscript`, use: - `docker exec -u git gitea_container_name sh -c 'gitea manager logging release-and-reopen'` BEST - `docker exec gitea_container_name sh -c '/bin/s6-svc -1 /etc/s6/gitea/` relies on s6 (foolproof way used in most cases, but in this case we have a built-in way which is better) - `kill -USR1 $(docker inspect --format '{{.State.Pid}}' "$gitea_container_name")` signal process directly
Author
Owner

@zeripath commented on GitHub (May 13, 2021):

I don't think the logging documentation is wrong - it's just not covering this usecase. It was never intended to provide information on how to run the command from outside of the container. I've added a PR to add your commands to the documentation though.

@zeripath commented on GitHub (May 13, 2021): I don't think the logging documentation is wrong - it's just not covering this usecase. It was never intended to provide information on how to run the command from outside of the container. I've added a PR to add your commands to the documentation though.
Author
Owner

@lonix1 commented on GitHub (May 13, 2021):

Thanks!

I'm a little confused though - isn't it normal to run it from the host (rather than the container)? One would expose the log file to the host (via a file volume, e.g. /var/log/gitea/gitea.log:/data/gitea/log/gitea.log), and rely on the host's logrotate to do the rotation. Then all the host's apps can be funneled into a log reporting tool.

I'm genuinely curious - how do you/others do it? And why would one perform log rotation inside the container?

@lonix1 commented on GitHub (May 13, 2021): Thanks! I'm a little confused though - isn't it normal to run it from the host (rather than the container)? One would expose the log file to the host (via a file volume, e.g. `/var/log/gitea/gitea.log:/data/gitea/log/gitea.log`), and rely on the host's logrotate to do the rotation. Then all the host's apps can be funneled into a log reporting tool. I'm genuinely curious - how do you/others do it? And why would one perform log rotation inside the container?
Author
Owner

@zeripath commented on GitHub (May 13, 2021):

Not everyone uses docker and it was assumed that any docker user who wanted to use this more advanced functionality would understand how to run it.

As we provide docker builds its not entirely unreasonable to provide information on how docker users could run things though - hence the PR.

@zeripath commented on GitHub (May 13, 2021): Not everyone uses docker and it was assumed that any docker user who wanted to use this more advanced functionality would understand how to run it. As we provide docker builds its not entirely unreasonable to provide information on how docker users could run things though - hence the PR.
Author
Owner

@lonix1 commented on GitHub (May 13, 2021):

LOL... I forgot that not everyone uses docker! 😄

Should we close this issue now?

PS thanks for all the work you do on gitea, it's really great!

@lonix1 commented on GitHub (May 13, 2021): LOL... I forgot that not everyone uses docker! :smile: Should we close this issue now? PS thanks for all the work you do on gitea, it's really great!
Author
Owner

@zeripath commented on GitHub (May 13, 2021):

the PR will close it when it's merged. So it's fine to leave it open.

@zeripath commented on GitHub (May 13, 2021): the PR will close it when it's merged. So it's fine to leave it open.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7328