Skip to content

How to set proper custom config file? #2174

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
z0rr0 opened this issue Dec 13, 2015 · 29 comments
Closed

How to set proper custom config file? #2174

z0rr0 opened this issue Dec 13, 2015 · 29 comments
Labels
🤷 third-party It's someone else's shit

Comments

@z0rr0
Copy link

z0rr0 commented Dec 13, 2015

Custom config /opt/gogs/custom/conf/app.ini was removed from debian package ver. 0.8.0, so custom configuration settings are not used. As I understand it was done in the commit fa8bf0f.

How can I set custom settings?

Gogs deb package version: 0.8.0-1449979765.4df378b.trusty
OS: Ubuntu GNU/Linux 14.04 3.13.0-71-generic x86_64
Git: 1.9.1

@stonerl
Copy link

stonerl commented Dec 13, 2015

/etc/gogs/conf/app.ini

@z0rr0
Copy link
Author

z0rr0 commented Dec 13, 2015

@stonerl , the file /etc/gogs/conf/app.ini contains a header:

# NEVER EVER MODIFY THIS FILE
# PLEASE MAKE CHANGES ON CORRESPONDING CUSTOM CONFIG FILE

I am not sure it's a good idea to edit it.

@stonerl
Copy link

stonerl commented Dec 13, 2015

That's because it takes the file from /opt/gogs/conf/ and copies it to /etc/gogs/conf you must not change the file into /opt/...

-----Original Message-----
From: Alexander Zaytsev [email protected]
To: gogits/gogs [email protected]
Cc: "Toni Förster" [email protected]
Sent: Sun, 13 Dec 2015 19:03
Subject: Re: [gogs] How to set proper custom config file? (#2174)

@stonerl , the file /etc/gogs/conf/app.ini contains a header:

# NEVER EVER MODIFY THIS FILE
# PLEASE MAKE CHANGES ON CORRESPONDING CUSTOM CONFIG FILE

I am not sure it's a good idea to edit it.


Reply to this email directly or view it on GitHub:
#2174 (comment)

@stonerl
Copy link

stonerl commented Dec 13, 2015

@z0rr0 have a look here: https://gogs.io/docs/advanced/configuration_cheat_sheet custom/conf/app.inidoes not exist anymore for the deb packages. Therefore you have to use /etc/gogs/conf/app.ini

@stonerl
Copy link

stonerl commented Dec 13, 2015

This has been changed because some users where hitting a severe bug #1897

@unknwon
Copy link
Member

unknwon commented Dec 13, 2015

cc @crohr :

I think it's not a good idea to keep full version of default configuration as default configuration may have bug sometimes, so the best way is just use the parts that user customized.

In this case,

  • Is it possible to check if user is installing Gogs for the first time? If yes, remove the default /etc/gogs/conf/app.ini and let Gogs generates a partially modified one itself.
  • for second or later time, just keep the way right now.

How do you think?

@unknwon unknwon added 🔨 enhancement Make it better, faster 🤷 third-party It's someone else's shit status: await It is time consuming labels Dec 13, 2015
@unknwon unknwon added this to the 0.9.0 milestone Dec 13, 2015
@unknwon unknwon removed this from the 0.9.0 milestone Feb 7, 2016
@unknwon
Copy link
Member

unknwon commented Feb 7, 2016

@z0rr0 what is the situation of this issue now...?

@unknwon unknwon added the status: needs feedback Tell me more about it label Feb 7, 2016
@z0rr0
Copy link
Author

z0rr0 commented Feb 7, 2016

@unknwon I don't know how to set custom configuration properly.

One my project uses ubuntu-based docker image with gogs deb package. It rewrited a custom config file and worked well before.

@unknwon
Copy link
Member

unknwon commented Feb 7, 2016

I don't know how to set custom configuration properly.

What does this mean? What is the definition of your properly?

@z0rr0
Copy link
Author

z0rr0 commented Feb 7, 2016

@unknwon properly means a proper file, /opt/gogs/custom/conf/app.ini and /etc/gogs/conf/app.ini don't work. My usecase is: 1) install gogs 2) create a custom config 3) run gogs

Do I right understand that gogs replaces /etc/gogs/conf/app.ini during the first start?

@unknwon
Copy link
Member

unknwon commented Feb 7, 2016

@z0rr0 No, Gogs replaces nothing. It was replaced by packager.io builder, but I think they have fixed this problem.

@unknwon unknwon added 🤷 third-party It's someone else's shit and removed status: await It is time consuming 🔨 enhancement Make it better, faster 🤷 third-party It's someone else's shit labels Feb 7, 2016
@z0rr0
Copy link
Author

z0rr0 commented Feb 7, 2016

@unknwon I see this behavior using a package 0.8.25-1454711359.e797a22.trusty

@unknwon
Copy link
Member

unknwon commented Feb 7, 2016

According to https://github.com/gogits/gogs/blob/master/packager/hooks/postinst#L18 , you should use /etc/gogs/conf/app.ini.

@z0rr0
Copy link
Author

z0rr0 commented Feb 7, 2016

I use this app.ini and can login through web, but git pull returns:

Gogs: Internal error
Failed to get repository owner (user): dial tcp 127.0.0.1:3306: getsockopt: connection refused
fatal: Could not read from remote repository.

And /var/log/gogs/serv.log contains:

 [...ts/gogs/cmd/serve.go:167 runServ()] [F] Failed to get repository owner (user): dial tcp 127.0.0.1:3306: getsockopt: connection refused

Why IP 127.0.0.1 is used to connect to database? My configuration has no this value.

@unknwon
Copy link
Member

unknwon commented Feb 7, 2016

If you use MySQL, 127.0.0.1 is the default value.

So what database are you using exactly?

@z0rr0
Copy link
Author

z0rr0 commented Feb 7, 2016

@unknwon yes, it's expected, but can I set another value? My custom app.ini contains a name of remote MySQL host HOST = mysqlhost:3306 in section [database].

I used a configuration file /opt/gogs/custom/conf/app.ini with gogs deb package 0.7.33, it worked without any problems. I moved the file to /etc/gogs/conf/app.ini and tried to use new version of the package, but got "database connection refused" error for some operations.

@unknwon
Copy link
Member

unknwon commented Feb 7, 2016

Can you the stdout of Gogs? Because Gogs prints which custom file it uses there.

@z0rr0
Copy link
Author

z0rr0 commented Feb 7, 2016

2016/02/07 20:57:44 [T] Custom path: /etc/gogs
2016/02/07 20:57:44 [T] Log path: /opt/gogs/log
2016/02/07 20:57:44 [I] Softlation Git Repository 0.8.31.0205
2016/02/07 20:57:44 [I] Log Mode: File(Info)
2016/02/07 20:57:44 [I] Cache Service Enabled
2016/02/07 20:57:44 [I] Session Service Enabled
2016/02/07 20:57:44 [I] Mail Service Enabled
2016/02/07 20:57:44 [I] Notify Mail Service Enabled
2016/02/07 20:57:44 [I] Git Version: 1.9.1
2016/02/07 20:57:44 [I] Migration: generate rands and salt for organizations
2016/02/07 20:57:44 [I] Run Mode: Production
2016/02/07 20:57:44 [T] Doing: CheckRepoStats
2016/02/07 20:57:45 [I] Listen: http://0.0.0.0:9000
grep "127.0.0.1\|3306" /etc/gogs/conf/app.ini 
HOST = mysql:3306
; memcache: `127.0.0.1:11211`

@unknwon
Copy link
Member

unknwon commented Feb 7, 2016

@z0rr0
Copy link
Author

z0rr0 commented Feb 7, 2016

@unknwon It helped! All works perfect. Thank you very much!

@unknwon
Copy link
Member

unknwon commented Feb 7, 2016

@z0rr0 Great, so there wasis an old binary lives somewhere that still reads wrong configuration.

@unknwon unknwon closed this as completed Feb 7, 2016
@unknwon unknwon removed the status: needs feedback Tell me more about it label Feb 7, 2016
@trompx
Copy link

trompx commented Feb 24, 2016

Hello,

I am struggling to run gogs without install step with docker (ubuntu 14.04)

So in my Dockerfile I add a custom app.ini in a temporary folder at image build, then in the start.sh, once the /data/gogs folder are created (i added /data/gogs/custom/conf in the create_volume_subfolder function), I sed the custom app.ini file to update variable like domain / db_type and set INSTALL_LOCK = true.

But when I run the gogs container (with -v /gogs:/data), and browse my_server_ip:proxy_port, I hit directly the install page. If I exec -it bash in the container, I see my custom app.ini at /data/gogs/custom/conf/app.ini but it is not used. Before install, no other app.ini file is present on the image when I find / -name app.ini, only the custom one I added.

I am a bit lost with all the paths :

  • /opt/gogs/custom/conf/app.ini
  • /etc/gogs/conf/app.ini
  • /data/gogs/custom/conf/app.ini

Which one is the correct one (the one gogs reads before install step) that I need to edit/create to skip this install step ?

I tried with gogs/gogs:latest and 0.8.25

Thanks

@unknwon
Copy link
Member

unknwon commented Feb 24, 2016

@trompx For the Docker case, please read https://github.com/gogits/gogs/blob/master/docker/README.md

@trompx
Copy link

trompx commented Feb 24, 2016

I already did, and it's quite unclear.

On this page, Settings - Applications. Are the settings the one we are supposed to fill on the install page ? If yes, that's those variables I'd like to set in a custom app.ini file to not have to fill them at install.
Or are these variable (just like RUN_CROND) environment variables that we can pass at docker run ? (which would be awesome).

In the same section of the page your mentionned, a link redirect to https://gogs.io/docs/advanced/configuration_cheat_sheet.html which talks about the custom app.ini file (while it is not mentionned on the docker gogs page). So where does this file is supposed to be in the first place ? running the gogs/gogs:latest just after pulling it from the repo, doing find / -name app.ini returns no result, no app.ini, no custom app.ini either.

So where are those files, when are they created, or where are we supposed to create them ?

@unknwon
Copy link
Member

unknwon commented Feb 24, 2016

It is very clear where the custom files are stored:

/var/gogs
|-- git
|   |-- gogs-repositories
|-- ssh
|   |-- # ssh public/private keys for Gogs
|-- gogs
    |-- conf
    |-- data
    |-- log

/var/gogs/gogs/conf/app.ini (based on the example in the README, not every case, adjust your own values).

@trompx
Copy link

trompx commented Feb 24, 2016

At https://gogs.io/docs/advanced/configuration_cheat_sheet.html, custom/conf/app.ini is a path.

At https://github.com/gogits/gogs/blob/master/docker/README.md, the directory structure you copied is refered to as the local path /var/gogs. And there is not the custom folder in any of them.

So you are saying that the custom = var/gogs ? If that is the case, the documentation was a bit misleading, but that would solve my problem I guess.

@unknwon
Copy link
Member

unknwon commented Feb 24, 2016

You only need to follow the README unless you want to dig into details: https://github.com/gogits/gogs/blob/master/Dockerfile#L9

custom is just a name, like computer, you can call it windows crap as you prefer, but it is still a computer.

@trompx
Copy link

trompx commented Feb 24, 2016

Thanks for the clarification.

@toddkaufmann
Copy link

I found this very confusing as well. Maybe it's more so for docker where there isn't an existing directory with app.ini. The docs that say

... if you are not allowed to edit conf/app.ini? Well, create custom/conf/app.ini ...

led me to think I should create a folder called custom at the same level as conf.
It would be more clear with a metavariable such as <gogsRoot>/ or $gogsRoot/.

After trying strace to see what files gogs was trying to read, and reading many messages here, I did see this a few thousand lines back in my terminal buffer:
2016/03/30 06:35:52 [T] Custom path: /data/gogs

Apparently this message only goes to stdout, not the log file? This info though is the most useful, especially when trying to find where configuration is read from and what the values are.

Also helpful would be clarification that if app.ini doesn't exist, it will get created for you
(and when you write it you can add a header message
"; This it your config file, created by gogs 0.9.15.0323; please edit to customize your server"
this would be useful when upgrading or looking at release notes to see what new settings might exist etc.

Otherwise it's working pretty well! Thanks.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🤷 third-party It's someone else's shit
Projects
None yet
Development

No branches or pull requests

5 participants