Skip to content

Commit

Permalink
feat(config): update default LISTEN_ADDR
Browse files Browse the repository at this point in the history
  • Loading branch information
a-wing committed Dec 30, 2022
1 parent 973bd91 commit 2f9f08d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ DATABASE_URL=postgres://postgres:password@localhost/gosd?sslmode=disable \

Variable Name | Description | Default
-------------- | -------------------------------------------------------- | -------------------------------------------------------------
`DEBUG` | Set the value to `1` to enable debug logs | Off
`DEMO_MODE` | Auto Run `database migrate`, `database seed`, `node sync`| Off
`LISTEN_ADDR` | Address to listen on (use absolute path for Unix socket) | `0.0.0.0:8000`
`DEBUG` | Set the value to `1` to enable debug logs | `false`
`DEMO_MODE` | Auto Run `database migrate`, `database seed`, `node sync`| `false`
`DATABASE_URL` | Postgresql connection parameters | `postgres://postgres:password@localhost/gosd?sslmode=disable`
`STORAGE_URL` | File storage path | `data/storage`
`LISTEN_ADDR` | Address to listen on (use absolute path for Unix socket) | `127.0.0.1:8000`
`PORT` | Override `LISTEN_ADDR` to `0.0.0.0:$PORT` (PaaS) | None
`BASE_URL` | Base URL to generate API links and base path | `http://localhost:8000/gosd/api/v3`
`MQTT_URL` | MQTT broker Server address | `mqtt://admin:public@localhost:1883`
`REDIS_URL` | Redis Server URL | `redis://localhost:6379/0`
Expand Down
5 changes: 3 additions & 2 deletions app/cmd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ func NewHandler(ctx context.Context, cfg *config.Config) http.Handler {

func Daemon(ctx context.Context) {
log.Warn("Launch gosd V3")
handler := NewHandler(ctx, config.Parse())
cfg := config.Parse()
handler := NewHandler(ctx, cfg)
log.Warn("=== RUN ===")

http.ListenAndServe(":8000", handler)
http.ListenAndServe(cfg.ListenAddr, handler)
}
2 changes: 2 additions & 0 deletions app/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func init() {
}

type Config struct {
ListenAddr string `env:"LISTEN_ADDR"`
Instance string `env:"INSTANCE"`
BaseURL string `env:"BASE_URL"`
MqttURL string `env:"MQTT_URL"`
Expand All @@ -35,6 +36,7 @@ var opts = DefaultConfig()

func DefaultConfig() *Config {
return &Config{
ListenAddr: "0.0.0.0:8000",
Instance: "gosd.0",
BaseURL: "http://localhost:8000/gosd/api/v3",
MqttURL: "mqtt://admin:public@localhost:1883",
Expand Down

0 comments on commit 2f9f08d

Please sign in to comment.