2021-01-08 21:37:38 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/kelseyhightower/envconfig"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config keeps info about configuration of this daemon
|
|
|
|
type Config struct {
|
2021-04-25 22:57:05 +00:00
|
|
|
Token string `envconfig:"TOKEN" required:"true"`
|
2021-01-30 11:33:57 +00:00
|
|
|
AppsPath string `envconfig:"APPS_PATH" default:"/srv"` // Where applications are located
|
|
|
|
AppsBindIPHTTP string `envconfig:"APPS_BIND_IP_HTTP" default:"0.0.0.0"` // On what IP apps' HTTP port gonna be bound
|
|
|
|
AppsBindIPSSH string `envconfig:"APPS_BIND_IP_SSH" default:"0.0.0.0"` // On what IP apps' SSH ports gonna be bound
|
2021-04-25 22:57:05 +00:00
|
|
|
NATSURL string `envconfig:"NATS_URL" required:"true"`
|
|
|
|
NATSAlias string `envconfig:"NATS_ALIAS" required:"true"` // name/alias of the instance, ex. node-18
|
|
|
|
DatabasePath string `envconfig:"DATABASE_PATH" default:"/var/lib/node-api/rosti.db"`
|
2021-01-08 21:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetConfig return configuration created based on environment variables
|
|
|
|
func GetConfig() *Config {
|
|
|
|
var config Config
|
|
|
|
|
|
|
|
err := envconfig.Process("", &config)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err.Error())
|
|
|
|
}
|
|
|
|
|
|
|
|
return &config
|
|
|
|
}
|