2022-01-02 21:30:56 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-12-15 04:00:26 +04:00
|
|
|
"encoding/json"
|
2022-01-02 21:30:56 +04:00
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Configuration struct {
|
2023-12-15 04:00:26 +04:00
|
|
|
ListenAddress string `json:"listen-address"`
|
|
|
|
Processes []Process `json:"processes"`
|
2022-01-02 21:30:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
func LoadConfiguration(path string) (conf *Configuration, err error) {
|
2023-12-15 04:00:26 +04:00
|
|
|
f, err := os.Open(path)
|
2022-01-02 21:30:56 +04:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2023-12-15 04:00:26 +04:00
|
|
|
defer f.Close()
|
2022-01-02 21:30:56 +04:00
|
|
|
|
2023-12-15 04:00:26 +04:00
|
|
|
conf = &Configuration{}
|
2022-01-02 21:30:56 +04:00
|
|
|
|
2023-12-15 04:00:26 +04:00
|
|
|
if err := json.NewDecoder(f).Decode(conf); err != nil {
|
|
|
|
return nil, err
|
2022-01-02 21:30:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return conf, nil
|
|
|
|
}
|