Skip to content

Gitea 1.3.0 fails to start #3052

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
klingtnet opened this issue Dec 1, 2017 · 10 comments
Closed

Gitea 1.3.0 fails to start #3052

klingtnet opened this issue Dec 1, 2017 · 10 comments
Labels

Comments

@klingtnet
Copy link

klingtnet commented Dec 1, 2017

I just upgrade to gitea 1.3.0 from 1.2.3 and now the service fails to start.
The problem is that the oauth2 plugin seems to ignore the working directory:

$ echo $PWD
/home/gitea/gitea
$ /usr/bin/gitea web --port 10000 --config /home/gitea/gitea/custom/conf/app.ini
# ...
2017/12/01 16:17:18 [...uth/oauth2/oauth2.go:47 Init()] [E] Fail to create dir /usr/bin/data/sessions/oauth2: mkdir /usr/bin/data: permission denied

Gitea was build from source: https://github.com/klingtnet/klingt.net/blob/master/build/gitea/Makefile

@klingtnet
Copy link
Author

klingtnet commented Dec 1, 2017

This is where gitea crashes: /modules/auth/oauth2/oauth2.go#L45

@0rzech
Copy link
Contributor

0rzech commented Dec 3, 2017

I think the real issue is that by default Gitea wants to create its data directory next to executable file, what seems undesirable more often than not. IMHO, it should default to ${HOME}/gitea on Linux and similar directory on other supported operating systems.

@0rzech
Copy link
Contributor

0rzech commented Dec 3, 2017

@klingtnet Could you try to run Gitea the following way?

GITEA_CUSTOM='/home/gitea/gitea/custom' GODEBUG=netdns=go /usr/bin/gitea web --port 10000

It will pick your app.ini and assume anything else is relative to /home/gitea/gitea/custom, AFAIK. This way you won't have to rely on PWD. This is also how it is done in Dockerfile and it's the recommended way to override default custom directory placement.

PS. The GODEBUG=netdns=go is not required, but seems to be a good choice for performance reasons, unless your networking setup is too complicated for Go's net library.
PS. II Please make backups before experimenting with the way you run Gitea. I don't take any responsibility. You know your setup best and if you choose to follow my advices, you do it at your own risk.

@klingtnet
Copy link
Author

@0rzech Thank you for your detailed response.
I tried to set GITEA_CUSTOM—also double checked its value—but the error is still the same, i.e. gitea tries to write to /usr/bin/data.

@0rzech
Copy link
Contributor

0rzech commented Dec 3, 2017

@klingtnet You're welcome. Could you also post APP_DATA_PATH setting value from your app.ini? I guess it might have been set to /usr/bin/data during installation due to lack of GITEA_CUSTOM environment variable.

@klingtnet
Copy link
Author

You're a wizard, setting APP_DATA_PATH fixed the problem!
The key did not exist in my app.ini so I added APP_DATA_PATH = /home/gitea/gitea/data to the [server] section.

@klingtnet
Copy link
Author

klingtnet commented Dec 3, 2017

I have closed the issue but may considerto set APP_DATA_PATH to pwd if unset?

klingtnet added a commit to klingtnet/klingt.net that referenced this issue Dec 3, 2017
This also sets the GITEA_CUSTOM environment variable because this is the
recommended instead of setting the working directory.
See go-gitea/gitea#3052 for details.
@0rzech
Copy link
Contributor

0rzech commented Dec 3, 2017

@klingtnet If APP_DATA_PATH was absent, then Gitea defaulted to "next-to-binary location".

I think the best way is to run Gitea using the command I presented in my second comment. Once you added the APP_DATA_PATH to your app.ini, it should work fine from now on. This means the conf/app.ini should be in data directory as well, resulting in /home/gitea/data/conf/app.ini.

Also make sure all other paths in your app.ini are set to proper values and all existing data is in right place.

@klingtnet
Copy link
Author

@0rzech One note to GODEBUG=netdns=go, it looks like this is already the default behaviour and does not need to be set explicitly: https://golang.org/src/net/net.go

@0rzech
Copy link
Contributor

0rzech commented Dec 3, 2017

@klingtnet Yes, you're right. I have even pointed it out myself here.

Btw. it looks like your installation might become a bit messy, because you have /home/gitea/gitea/custom and /home/gitea/data now. GITEA_CUSTOM is better to have the same value as APP_DATA_PATH, IMO. If everything is kept default except for GITEA_CUSTOM itself, then your Gitea directories should look like:

${GITEA_CUSTOM}/avatars
${GITEA_CUSTOM}/conf
${GITEA_CUSTOM}/indexers
${GITEA_CUSTOM}/log
${GITEA_CUSTOM}/sessions

etc.

klingtnet added a commit to klingtnet/klingt.net that referenced this issue Dec 3, 2017
It is now set to the same value as APP_DATA_PATH in the server config
section as suggested by
go-gitea/gitea#3052 (comment)
klingtnet added a commit to klingtnet/klingt.net that referenced this issue Dec 16, 2017
This also sets the GITEA_CUSTOM environment variable because this is the
recommended instead of setting the working directory.
See go-gitea/gitea#3052 for details.
klingtnet added a commit to klingtnet/klingt.net that referenced this issue Dec 16, 2017
It is now set to the same value as APP_DATA_PATH in the server config
section as suggested by
go-gitea/gitea#3052 (comment)
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants