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
44.16k stars 5.41k forks source link

Log mode changed to console after installation #24861

Closed alex-ibb closed 1 year ago

alex-ibb commented 1 year ago

Description

Docker image: gitea/gitea:1.19.3 Platform: x64 OS: Ubuntu 22.04.3 Server (Minimized)

Problem: the value of log__MODE changed to console after the initialization step.

Steps to reproduce:

  1. Install the OS, docker and docker-compose
  2. Draft an docker-compose.yml file with the following log related section:

      # [log]
      - GITEA__log__MODE=file
      - GITEA__log__LEVEL=Info
      - GITEA__log__ROUTER=file
      - GITEA__log__ROOT_PATH=/data/gitea/log/
      - GITEA__log__ENABLE_XORM_LOG=true #
      - GITEA__log__MAX_SIZE_SHIFT=28    # 单个日志文件最大大小,当为28时:2^28/1024^2=> 258(MB)
      - GITEA__log__FILE_NAME=gitea.log  # 即日志的路径为`/data/gitea/log/gitea.log`
      - GITEA__log__XORM=file
    
      # [log.file]
      - GITEA__log.file__MAX_DAYS=180 # 多少天后删除日志文件
      - GITEA__log.file__COMPRESSION_LEVEL=1 # 日志文件的压缩等级
    
      # [log.file.router]
      - GITEA__log.file.router__FILE_NAME=router.log
    
      # [log.file.xorm]
      - GITEA__log.file.xorm__FILE_NAME=xorm.log
  3. type docker-compose -f docker-compose.yml up -d to start the container and open its site for initialization.
  4. after filling the Administrator Account Settings section, using cat <container_root>/data/gitea/conf/app.ini to check log related settings, it reads:
    [log]
    MODE            = file
    LEVEL           = Info
    ROUTER          = file
    ROOT_PATH       = /data/gitea/log/
    ENABLE_XORM_LOG = true
    MAX_SIZE_SHIFT  = 28
    FILE_NAME       = gitea.log
    XORM            = file
  5. hit the Install Gitea button, the site would redirect to a user page, then re-check the content, it reads:
    [log]
    MODE            = console
    LEVEL           = info
    ROUTER          = console
    ROOT_PATH       = /data/gitea/log/
    ENABLE_XORM_LOG = true
    MAX_SIZE_SHIFT  = 28
    FILE_NAME       = gitea.log
    XORM            = file

The value of MODE changed to console incorrectly. To a personal unstandering, given in the docker-compose.yml it's file and all required values related have given, it should remind to be file after the initialization.

What have I missed ?

Gitea Version

1.19.3

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Using Docker images. The full content of the docker-compose.yml:

version: "3"

networks:
  gitea:
    external: false

volumes:
  gitea:
    driver: local

services:
  server:
    image: gitea/gitea:1.19.3
    container_name: lovegitea.gitea
    environment:
      - APP_NAME=Gitea@lovegitea
      - RUN_MODE=prod
      - USER_UID=3001
      - USER_GID=3000
      - USER=gitea_admin

      # [database]:https://docs.gitea.io/en-us/config-cheat-sheet/#database-database
      - GITEA__database__DB_TYPE=sqlite3
      - GITEA__database__DB_PATH="/data/gitea/gitea.db"

      # [repository]
      - GITEA__repository__DEFAULT_PRIVATE=private

      # [Server]:https://docs.gitea.io/en-us/config-cheat-sheet/#server-server
      - GITEA__server__DOMAIN=localhost
      # Git Clone over HTTP 相关
      - GITEA__server__HTTP_ADDR=
      - GITEA__server__HTTP_PORT=3000
      # - GITEA__server__ROOT_URL=

      # Git Clone over SSH
      - GITEA__server__DISABLE_SSH=false
      # - GITEA__server__SSH_DOMAIN=
      - GITEA__server__SSH_PORT=10022
      - GITEA__server__SSH_LISTEN_PORT=22
      - GITEA__server__OFFLINE_MODE=false
      - GITEA__server__LANDING_PAGE=login

      # [Service]
      - GITEA__service__DEFAULT_USER_IS_RESTRICTED=true
      - GITEA__service__OFFLINE_MODE=true
      - GITEA__service__DISABLE_REGISTRATION=true
      - GITEA__service__REQUIRE_SIGNIN_VIEW=true
      - GITEA__service__REGISTER_EMAIL_CONFIRM=true
      - GITEA__service__ENABLE_NOTIFY_MAIL=true
      - GITEA__service__ALLOW_ONLY_EXTERNAL_REGISTRATION=false
      - GITEA__service__ENABLE_CAPTCHA=false
      - GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE=false
      - GITEA__service__DEFAULT_ALLOW_CREATE_ORGANIZATION=true
      - GITEA__service__DEFAULT_ENABLE_TIMETRACKING=true
      - GITEA__service__NO_REPLY_ADDRESS=noreply.gitea.lovegitea.io
      - GITEA__service__DEFAULT_KEEP_EMAIL_PRIVATE=true
      - GITEA__service__DEFAULT_ORG_VISIBILITY=private

      # [Admin]
      - GITEA__admin__DEFAULT_EMAIL_NOTIFICATIONS=enabled
      - GITEA__admin__DISABLE_REGULAR_ORG_CREATION=false

      # [Security]
      - GITEA__security__LOGIN_REMEMBER_DAYS=1
      - GITEA__security__PASSWORD_HASH_ALGO=pbkdf2

      # [OpenID]
      - GITEA__openid__ENABLE_OPENID_SIGNIN=false
      - GITEA__openid__ENABLE_OPENID_SIGNUP=false

      # [Picture]
      - GITEA__picture__DISABLE_GRAVATAR=true
      - GITEA__picture__ENABLE_FEDERATED_AVATAR=false

      # [Git.Timeout]
      - GITEA__git.timeout__DEFAUlT=3600 # Git operations default timeout seconds.
      - GITEA__git.timeout__MIGRATE=3600 # Migrate external repositories timeout seconds.
      - GITEA__git.timeout__MIRROR=3600  # Mirror external repositories timeout seconds.
      - GITEA__git.timeout__CLONE=3600   # Git clone from internal repositories timeout seconds.
      - GITEA__git.timeout__PULL=3600    # Git pull from internal repositories timeout seconds.
      - GITEA__git.timeout__GC=3600      # Git repository GC timeout seconds.

      # [Other]
      - GITEA__other__SHOW_FOOTER_VERSION=false # Whether to show Gitea version on the site
      - GITEA__other__ENABLE_FEED=false         

      # [log]
      - GITEA__log__MODE=file
      - GITEA__log__LEVEL=Info
      - GITEA__log__ROUTER=file
      - GITEA__log__ROOT_PATH=/data/gitea/log/
      - GITEA__log__ENABLE_XORM_LOG=true #
      - GITEA__log__MAX_SIZE_SHIFT=28    # 2^28/1024^2 => 258(MB)
      - GITEA__log__FILE_NAME=gitea.log  # `/data/gitea/log/gitea.log`
      - GITEA__log__XORM=file

      # [log.file]
      - GITEA__log.FILE_NAME=/data/gitea/log/gitea.log
      - GITEA__log.file__MAX_DAYS=180 #
      - GITEA__log.COMPRESS=true
      - GITEA__log.file__COMPRESSION_LEVEL=1 #

      # [log.file.router]
      - GITEA__log.file.router__FILE_NAME=router.log

      # [log.file.xorm]
      - GITEA__log.file.xorm__FILE_NAME=xorm.log

    restart: unless-stopped
    networks:
      - gitea
    volumes:
      - /docker-data/containers/lovegitea.gitea/data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "10080:3000"
      - "10022:22" # activate this line to enable SSH Clone

Database

SQLite

yp05327 commented 1 year ago

It is changed in: https://github.com/go-gitea/gitea/blob/5c0745c0349f0709d0fc36fd8a97dcab86bce28a/routers/install/install.go#L462

alex-ibb commented 1 year ago

Thank you, @CypherpunkSamurai .

It seems it will be changed to 'console' after the initilization, regardless the value in the docker-compose file. To change it, one need to edit the app.ini after the initilization.

Wondering the considerations to force the values of MODE and ROUTER to console in the install.go. Seems confusing.

lunny commented 1 year ago

The change comes from d65cd5677af3df5d616bf48dfd4be354e23c184f, before that commit, it's file.

alex-ibb commented 1 year ago

Copy, thank you @lunny

@zeripath Hi~ For the commit, to change the default values of MODE and ROUTER, what are the considerations to hard-code them to "console"?

wxiaoguang commented 1 year ago

No particular reason.

-> Do not overwrite the log mode when installing #25203