mirror of
https://github.com/zedeus/nitter
synced 2024-11-24 10:49:27 +01:00
Implement config from env
This commit is contained in:
parent
2254a0728c
commit
e00dee501b
14
README.md
14
README.md
@ -100,9 +100,10 @@ $ cp nitter.example.conf nitter.conf
|
||||
```
|
||||
|
||||
Set your hostname, port, HMAC key, https (must be correct for cookies), and
|
||||
Redis info in `nitter.conf`. To run Redis, either run
|
||||
`redis-server --daemonize yes`, or `systemctl enable --now redis` (or
|
||||
redis-server depending on the distro). Run Nitter by executing `./nitter` or
|
||||
Redis info in `nitter.conf` or Environment Variables in format of
|
||||
`NITTER_SECTION_KEY=xxxx` in upper case (for example: NITTER_SERVER_HOSTNAME=nitter.net).
|
||||
To run Redis, either run `redis-server --daemonize yes`, or `systemctl enable --now redis`
|
||||
(or redis-server depending on the distro). Run Nitter by executing `./nitter` or
|
||||
using the systemd service below. You should run Nitter behind a reverse proxy
|
||||
such as [Nginx](https://github.com/zedeus/nitter/wiki/Nginx) or
|
||||
[Apache](https://github.com/zedeus/nitter/wiki/Apache) for security and
|
||||
@ -125,6 +126,13 @@ docker build -t nitter:latest .
|
||||
docker run -v $(pwd)/nitter.conf:/src/nitter.conf -d --network host nitter:latest
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
docker build -t nitter:latest .
|
||||
docker run -e NITTER_SERVER_ADDRESS=0.0.0.0 -e NITTER_SERVER_PORT=8080 -d --network host nitter:latest
|
||||
```
|
||||
|
||||
Note: For ARM64, use this Dockerfile: [`Dockerfile.arm64`](https://github.com/zedeus/nitter/blob/master/Dockerfile.arm64).
|
||||
|
||||
A prebuilt Docker image is provided as well:
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Config can be set via Environment Variables in format of `NITTER_SECTION_KEY`.
|
||||
# Environment Variables override nitter.conf.
|
||||
[Server]
|
||||
hostname = "nitter.net" # for generating links, change this to your own domain/ip
|
||||
title = "nitter"
|
||||
|
@ -1,9 +1,11 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
import parsecfg except Config
|
||||
import types, strutils
|
||||
import types, strutils, std/os
|
||||
|
||||
proc get*[T](config: parseCfg.Config; section, key: string; default: T): T =
|
||||
let val = config.getSectionValue(section, key)
|
||||
let envKey = "NITTER_" & section.toUpperAscii & "_" & key.toUpperAscii
|
||||
let envVal = getEnv(envKey)
|
||||
let val = if envVal.len == 0: config.getSectionValue(section, key) else: envVal
|
||||
if val.len == 0: return default
|
||||
|
||||
when T is int: parseInt(val)
|
||||
@ -11,7 +13,7 @@ proc get*[T](config: parseCfg.Config; section, key: string; default: T): T =
|
||||
elif T is string: val
|
||||
|
||||
proc getConfig*(path: string): (Config, parseCfg.Config) =
|
||||
var cfg = loadConfig(path)
|
||||
var cfg = try: loadConfig(path) except IOError: parseCfg.Config()
|
||||
|
||||
let conf = Config(
|
||||
# Server
|
||||
|
Loading…
Reference in New Issue
Block a user