Service failed to start, so: $ gitea 2019/05/30 00:08:13 [T] AppPath: /usr/local/sbin/gitea 2019/05/30 00:08:13 [T] AppWorkPath: /usr/local/sbin 2019/05/30 00:08:13 [T] Custom path: /usr/local/sbin/custom 2019/05/30 00:08:13 [T] Log path: /usr/local/sbin/log 2019/05/30 00:08:13 [I] Gitea v1.8.1 built with go1.12.5 2019/05/30 00:08:13 [I] Log Mode: Console(Info) 2019/05/30 00:08:13 [I] XORM Log Mode: Console(Info) 2019/05/30 00:08:13 [I] Cache Service Enabled panic: fail to set message file(en-US): open conf/locale/locale_en-US.ini: no such file or directory goroutine 1 [running]: code.gitea.io/gitea/vendor/github.com/go-macaron/i18n.initLocales(0xc0004ad135, 0x0, 0x15fa5ca, 0xb, 0xc0006c6900, 0x160834f, 0x12, 0xc0000ec420, 0x16, 0x16, ...) /usr/ports/www/gitea/work/src/code.gitea.io/gitea/vendor/github.com/go-macaron/i18n/i18n.go:57 +0x6de code.gitea.io/gitea/vendor/github.com/go-macaron/i18n.I18n(0xc0004d2240, 0x1, 0x1, 0x0, 0x0) /usr/ports/www/gitea/work/src/code.gitea.io/gitea/vendor/github.com/go-macaron/i18n/i18n.go:158 +0xed code.gitea.io/gitea/routers/routes.NewMacaron(0xc000656a00) /usr/ports/www/gitea/work/src/code.gitea.io/gitea/routers/routes/routes.go:126 +0x7af code.gitea.io/gitea/cmd.runWeb(0xc000656a00, 0x0, 0x0) /usr/ports/www/gitea/work/src/code.gitea.io/gitea/cmd/web.go:125 +0xae code.gitea.io/gitea/vendor/github.com/urfave/cli.HandleAction(0x13dd7a0, 0x16589f8, 0xc000656a00, 0xc0000877a0, 0x0) /usr/ports/www/gitea/work/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:471 +0xad code.gitea.io/gitea/vendor/github.com/urfave/cli.(*App).Run(0xc0004d0820, 0xc00003c1a0, 0x1, 0x1, 0x0, 0x0) /usr/ports/www/gitea/work/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:246 +0x574 main.main() /usr/ports/www/gitea/work/src/code.gitea.io/gitea/main.go:57 +0x426 root@3rr0r:/usr/ports/www/gitea # ls /usr/local/etc/gitea/conf/app.ini app.ini app.ini.defaults app.ini.sample
I'm having the same issue on FreeBSD 12 and gitea 1.8.1. The issue seems to be in the daemonization within the rc script. # /usr/sbin/daemon -S -l daemon -s debug -T gitea -u git -p /var/run/gitea.pid /usr/bin/env -i 'GITEA_WORK_DIR=/usr/local/share/gitea' 'GITEA_CUSTOM=/usr/local/etc/gitea' 'HOME=/usr/local/git' 'PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' 'USER=git' /usr/local/sbin/gitea web exits with no error or output, and nothing in the log. However, when I run: # su git $ /usr/bin/env -i 'GITEA_WORK_DIR=/usr/local/share/gitea' 'GITEA_CUSTOM=/usr/local/etc/gitea' 'HOME=/usr/local/git' 'PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' 'USER=git' /usr/local/sbin/gitea web It works just fine.
And strangely, once I ran that once, now the rc script works when I reboot the jail that gitea is running in. So now everything seems to be working for me. TLDR; Workaround: # su git $ /usr/bin/env -i 'GITEA_WORK_DIR=/usr/local/share/gitea' 'GITEA_CUSTOM=/usr/local/etc/gitea' 'HOME=/usr/local/git' 'PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' 'USER=git' /usr/local/sbin/gitea web ctrl-c $ exit # service start gitea
Ahhh. I've found the issue in the debug.log. After the upgrade (from 1.4 to 1.8.1) it couldn't write the JWT_SECRET due to a permissions issue. For some reason, starting it manually as user git allowed that access, and now the JWT secret is written. ... May 29 22:53:27 git gitea[40628]: 2019/05/29 22:53:27 ^[[1;31m[...s/setting/setting.go:729 NewContext()] [E] error saving generating JWT secret to custom config: open /usr/local/etc/gitea/conf/app.ini: permission denied^[[0m May 29 22:54:32 git gitea[47246]: 2019/05/29 22:54:32 ^[[1;31m[...s/setting/setting.go:729 NewContext()] [E] error saving generating JWT secret to custom config: open /usr/local/etc/gitea/conf/app.ini: permission denied^[[0m May 29 22:59:51 git gitea[63870]: 2019/05/29 22:59:51 ^[[1;31m[...s/setting/setting.go:729 NewContext()] [E] error saving generating JWT secret to custom config: open /usr/local/etc/gitea/conf/app.ini: permission denied^[[0m ...
Thank you so much for your workaround. When I did as you suggested. $ su git $ /usr/bin/env -i 'GITEA_WORK_DIR=/usr/local/share/gitea' 'GITEA_CUSTOM=/usr/local/etc/gitea' 'HOME=/usr/local/git' 'PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' 'USER=git' /usr/local/sbin/gitea web 2019/05/30 04:08:35 [...s/setting/setting.go:729 NewContext()] [E] error saving generating JWT secret to custom config: open /usr/local/etc/gitea/conf/app.ini: permission denied So, I did: $ chown git:git /usr/local/etc/gitea/conf/app.ini $ su git $ /usr/bin/env -i 'GITEA_WORK_DIR=/usr/local/share/gitea' 'GITEA_CUSTOM=/usr/local/etc/gitea' 'HOME=/usr/local/git' 'PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' 'USER=git' /usr/local/sbin/gitea web 2019/05/30 04:09:50 [T] AppPath: /usr/local/sbin/gitea 2019/05/30 04:09:50 [T] AppWorkPath: /usr/local/share/gitea 2019/05/30 04:09:50 [T] Custom path: /usr/local/etc/gitea 2019/05/30 04:09:50 [T] Log path: /var/log/gitea 2019/05/30 04:09:50 [I] Gitea v1.8.1 built with go1.12.5 ^C $ service gitea start $ service gitea status gitea is running as pid 71460. I guess it should be done by the port, so this is a bug. Thank you so much!
Unfortunately, Gitea does not really use a "standard" file layout for config files, messages catalogs, templates, etc., but expects them to live right next to the executable binary. In the FreeBSD port, I'm installing the files in the places that a FreeBSD user would expect them to live ($PREFIX/etc, $PREFIX/share, ...). The start script will run gitea with appropriate command line arguments to direct it to the correct location of these files. That means that running gitea without any such command line arguments will fail. Also note that running gitea as root will likely mess up permissions, as gitea expects to run as (and be able to modify files as) the git user. The start script uses daemon(8) to write the output of the gitea process to syslog as daemon:debug. Either configure syslog to write debug output to a file, or set gitea_facility and gitea_priority in rc.conf to values that make messages show up in an existing log file. For example, setting gitea_priority=error and (re-)starting the gitea service should make those messages appear in /var/log/messages. Also note that when upgrading from an earlier release to Gitea 1.8.x, you need to add a new config option, or set permissions on the config file so gitea can add the option itself. See pkg-message for details.
(In reply to Mohammad S. Babaei from comment #4) > $ chown git:git /usr/local/etc/gitea/conf/app.ini > I guess it should be done by the port, so this is a bug. No, as a general rule: config files are managed by the system admin, and they should not be writeable by the daemon process. If you'd like to have gitea be able to modify the config file for you, then by all means set the permissions as you'd like. Please see pkg-message and /usr/ports/UPDATING when upgrading ports.
Thank you so much for the extra information and clear explanation.