Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ var exitOnStop = flag.Bool("exit-on-stop", true, "Exit goreman if all subprocess
// show timestamp in log
var logTime = flag.Bool("logtime", true, "show timestamp in log")

var envFileOption = flag.String("env", ".env", "Environment files to load, comma separated")

var maxProcNameLength = 0

var re = regexp.MustCompile(`\$([a-zA-Z]+[a-zA-Z0-9_]+)`)
Expand All @@ -109,6 +111,7 @@ type config struct {
BaseDir string `yaml:"basedir"`
BasePort uint `yaml:"baseport"`
Args []string
EnvFiles []string
// If true, exit the supervisor process if a subprocess exits with an error.
ExitOnError bool `yaml:"exit_on_error"`
}
Expand All @@ -125,6 +128,7 @@ func readConfig() *config {
cfg.Port = *port
cfg.BaseDir = *basedir
cfg.BasePort = *baseport
cfg.EnvFiles = strings.FieldsFunc(*envFileOption, func(char rune) bool { return char == ',' })
cfg.ExitOnError = *exitOnError
cfg.Args = flag.Args()

Expand Down Expand Up @@ -263,7 +267,9 @@ func start(ctx context.Context, sig <-chan os.Signal, cfg *config) error {
procs = tmp
mu.Unlock()
}
godotenv.Load()
if len(cfg.EnvFiles) > 0 {
godotenv.Load(cfg.EnvFiles...)
}
rpcChan := make(chan *rpcMessage, 10)
if *startRPCServer {
go startServer(ctx, rpcChan, cfg.Port)
Expand Down