refactor: decouple application startup logic from main

This commit is contained in:
2026-01-23 23:51:58 +07:00
parent 24b9872aa4
commit d0e052524c
8 changed files with 214 additions and 164 deletions
+5
View File
@@ -18,6 +18,8 @@ type config struct {
httpPort string
httpsPort string
keyLoc string
tlsEnabled bool
tlsRedirect bool
@@ -51,6 +53,8 @@ func parse() (*config, error) {
httpPort := getenv("HTTP_PORT", "8080")
httpsPort := getenv("HTTPS_PORT", "8443")
keyLoc := getenv("KEY_LOC", "certs/privkey.pem")
tlsEnabled := getenvBool("TLS_ENABLED", false)
tlsRedirect := tlsEnabled && getenvBool("TLS_REDIRECT", false)
@@ -85,6 +89,7 @@ func parse() (*config, error) {
sshPort: sshPort,
httpPort: httpPort,
httpsPort: httpsPort,
keyLoc: keyLoc,
tlsEnabled: tlsEnabled,
tlsRedirect: tlsRedirect,
acmeEmail: acmeEmail,