Skip to content

Configuration

Forewing edited this page Mar 28, 2021 · 3 revisions

Configure methods

  1. By default, the server read all configs from command line flags.

  2. If flag -conf={FILE} is set, the server will load configs from {FILE} instead of flags. Refer to config.example.yml for detail.

  3. If the environment variable USE_ENV_CONFIG=true is set, the non-empty environment variable will override corresponding fields. Refer to example.env for detail.

Note: we are using environment variable fields' names here, you can easily map them to config files' or command flags' names by reading config.example.yml or ./goldennum -h.

Bind address & URL

  • Set bind to HOST:PORT, HOST should be set to 0.0.0.0 if you want to receive outside connections.

  • Base URL is useful when hosting multiple services under the same domain. In other words, the Goldennum server is not hosted at the root (/).

    For example, you are hosting your website at example.com, and using a reverse proxy to redirect https://example.com/goldennum/${uri} to http://localhost:8080/${uri}, where you host your server at.

    Then, you need to set BASE_URL to /goldennum, then the server knows to add prefix /goldennum for frontend statics URL, API paths...

Admin

  • Admin port uses HTTP Basic Auth, you need to set a username and password for it.

  • If password is empty, a safe random token will be used.

Database

SQLite3

  • DB_TYPE=sqlite3

  • DB_PATH sets the database path.

    You may also set it to file::memory:?cache=shared for an in-memory database when debugging. But be aware of shutting down the server will let you lost all of the data since SQLite3 will wipe it off when no connection is alive.

MySQL

  • DB_TYPE=mysql

  • DB_ADDR is the database server address with port, localhost:3306, eg.

  • DB_USER, DB_PASSWORD, DB_NAME for database username, password, name.

Connection pool

Note: you may not need to change those default settings.

  • MAX_CONNS, max open connections, default to 150.

  • MAX_IDLES, max idle connections, should be <= MAX_CONNS, default to MAX_CONNS * 0.25.

  • CONN_LIFE, how long can one connection keeps alive, default to 5.

Debug

  • Set DEBUG to true to enable debugging.
Clone this wiki locally