Gitea not starting (via supervisor) after updating from 1.6.4 to 1.7.0


#1

A few weeks ago I installed Gitea on a Debian 8 server, following the install instructions and opting for supervisor control. Everything was fine and I’ve been using Gitea since then with no problems.

Yesterday I decided to update to v.1.7.0, so I downloaded the new binary and linked it as gitea (I use “ln -s” to make a quick change to new files, while keeping the old ones).

The thing is, I cannot start the new version via supervisorctl:
supervisorctl start gitea
gitea: ERROR (abnormal termination)

All permissions are set to git:git

app.ini ets run user to git:
RUN_USER = git

stderr.log shows:
...s/setting/setting.go:1029 NewContext()] [E] Expect user 'git' but current user is: root

If I go back to v.1.6.4, the same configuration runs without errors.

I’m lost, any idea on how to solve this issue? Thanks!


#2

I have the same problem… I upgrade from 1.5.0 to 1.7.0 on CentOS 7 by download the new binary and relink my symlink. The binary don’t want to start.

I did a successful upgrade from 1.5.0. to 1.7.0 with a not used/clean database/gitea version.

panic: interface conversion: interface {} is float64, not bool

goroutine 1 [running]:
code.gitea.io/gitea/models/migrations.addPullRequestRebaseWithMerge(0xc000595e10, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/models/migrations/v76.go:44 +0x6e9
code.gitea.io/gitea/models/migrations.(*migration).Migrate(0xc000371d00, 0xc000595e10, 0xc0005b7650, 0x1)
	/go/src/code.gitea.io/gitea/models/migrations/migrations.go:53 +0x34
code.gitea.io/gitea/models/migrations.Migrate(0xc000595e10, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/models/migrations/migrations.go:247 +0x368
code.gitea.io/gitea/models.NewEngine(0x17fecd0, 0xc, 0xc0005b7788)
	/go/src/code.gitea.io/gitea/models/models.go:302 +0x70
code.gitea.io/gitea/routers.GlobalInit()
	/go/src/code.gitea.io/gitea/routers/init.go:60 +0x51a
code.gitea.io/gitea/cmd.runWeb(0xc000101540, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/cmd/web.go:121 +0xaa
code.gitea.io/gitea/vendor/github.com/urfave/cli.HandleAction(0x15a61a0, 0x17feb90, 0xc000101540, 0xc000163200, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:471 +0xad
code.gitea.io/gitea/vendor/github.com/urfave/cli.Command.Run(0x1780ec7, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x17a9747, 0x16, 0x0, ...)
	/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/command.go:191 +0x96d
code.gitea.io/gitea/vendor/github.com/urfave/cli.(*App).Run(0xc0001f31e0, 0xc00000c080, 0x2, 0x2, 0x0, 0x0)
	/go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:241 +0x5a2
main.main()
	/go/src/code.gitea.io/gitea/main.go:56 +0x42f

Any thoughts?


#3

Upgrade to Gitea 1.6.4 works fine but to 1.7.0 not


#4

This looks like not a Gitea issue, but try to turn on setgid and setuid permissions for the binary.


#5

You’re right, I investigated the issue and found it was a supervisor configuration error: I was running supervisorctl as root (unsafe habit, I know), to quickly solve a permission issue with the supervisor socket.

I found that Gitea checks the running user at line 1039 in setting.go:

If the running user is different from the RUN_USER = git defined in the Security section in app.ini.conf, Gitea exits via log.Fatal()

As I was running supervisorctl as root, Gitea found the inconsistence and correctly exited.

I solved the issue by reconfiguring supervisor, following this post:

Gitea 1.7.0 must have changed something (again, that’s correctly done from a security PoV), because I didn’t have this error with v.1.6.4.

@ruliezz
I don’t know if the above helps to solve your issue, I’m sorry I cannot reproduce it here, but I suggest to check the permissions, as hinted by @elfuego


#6

I have this issue too, and tried the supervisor reconfiguration, added my git user to the supervisor group, change the permission in the supervisor’s config to 0770 and added the chown=root:supervisor

but gitea 1.7.1 (nor 1.7.0) is still failing to start. In supervisor.log:

2019-02-03 09:45:43,526 INFO exited: gitea (exit status 1; not expected)
2019-02-03 09:45:44,528 INFO gave up: gitea entered FATAL state, too many start retries too quickly

1.6.3 is fine

EDIT: I’ve tried the setuid/setgid permission as well


#7

@Geobomatic
What’s in supervisor-gitea-stderr.log?

You can find the specific gitea error there. Mine was:

2019/01/25 12:48:21 …s/setting/setting.go:1029 NewContext()] [E] Expect user ‘git’ but current user is: root

Eventually I found there was a missing definition in my /etc/supervisor/conf.d/gitea.conf:

[program:gitea]

user=git ;<-- This is needed! Without it, supervisor runs gitea as root, not git

environment = HOME="/home/git", USER=“git” ;<-- this defines enviroment’s variables only!
directory=/home/git/ ;<-- I changed homedir, yours could be different
command=/home/git/gitea web
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/home/git/log/supervisor-gitea-stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stdout_logfile=/home/git/log/supervisor-gitea-stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB

Hope the above helps :slight_smile:


#8

Thanks for your answer!

my supervisor config for gitea:

[program:gitea]
directory=/home/git/
command=/home/git/gitea web
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/gitea/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/gitea/stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
environment = HOME="/home/git", USER="git"
user = git

I found in /var/log/gitea/stdout.log:

2019/02/03 12:22:13 [...s/setting/setting.go:1029 NewContext()] [E] Expect user 'git' but current user is: root

But now, after server reboot, neither 1.6.3 nor 1.7.1 are starting anymore and without this error, no error printed this time :-/

EDIT: with user=git none start, without it, 1.6 starts but 1.7 still not start, I’m missing something in my permissions


#9

Your configuration looks exactly like mine, and you get the same error as i did: supervisor runs gitea as “root”, and gitea stops because it needs to be run as “git”.

Please try removing the spaces in your gitea.conf arond the “=”, it’s the only difference I can see, please try:

environment = HOME="/home/git", USER=“git”
user=git

In neither this functions, we need to check the single permissions between your files and mine…


#10

I tried with no chance.

my permission on gitea:

-rwxr-xr-x 1 git  supervisor 62167024 Feb  3 16:05 gitea

on supervisor.sock:

srwxrwx---  1 root supervisor    0 Feb  3 16:06 supervisor.sock

#11

Got it! As it was running as root before, all the files in the working dir were root:root, I’ve chown -R git:git my whole ~git dir and it works now!

Thank you for the inspiration!


#12

Well done! :slight_smile:

I forgot to mention it, I think I had the same problem at some point, and gave exactly the same command, chown -R git:git /home/git

I’m happy you solved it, let’s hope this can be useful to some other users with the same problem.

Bye!


#13

Thanks, for you understanding I am not using supervisor but just the binary. I have tried to run is as git instead of gitea but still it complains about:

panic: interface conversion: interface {} is float64, not bool