Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func setupStartCmd() cli.Command {
cli.StringFlag{Name: "tmux-config, F", EnvVar: "OVERMIND_TMUX_CONFIG", Usage: "Specify an alternative tmux config path to be used by Overmind", Destination: &c.TmuxConfigPath},
cli.StringFlag{Name: "ignored-processes, x", EnvVar: "OVERMIND_IGNORED_PROCESSES", Usage: "Specify process names to prevent from launching. Useful if you want to run all but one or two processes. Divide names with comma. Takes precedence over the 'processes' flag.", Destination: &c.IgnoredProcNames},
cli.StringFlag{Name: "shell, H", EnvVar: "OVERMIND_SHELL", Usage: "Specify shell to run processes with.", Value: "sh", Destination: &c.Shell},
cli.StringFlag{Name: "env, e", EnvVar: "OVERMIND_ENV", Usage: "Environment file[,file] to load. Can specify multiple files separated by comma", Destination: &c.EnvFiles},
},
socketFlags(&c.SocketPath, &c.Network)...,
),
Expand Down
22 changes: 22 additions & 0 deletions start/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"syscall"

"github.com/DarthSim/overmind/v2/utils"
"github.com/Envek/godotenv"

"github.com/urfave/cli"
)
Expand Down Expand Up @@ -48,6 +49,7 @@ type Handler struct {
Daemonize bool
TmuxConfigPath string
Shell string
EnvFiles string
}

// AbsRoot returns absolute path to the working directory
Expand All @@ -65,6 +67,11 @@ func (h *Handler) AbsRoot() (string, error) {

// Run runs the start command
func (h *Handler) Run(c *cli.Context) error {
// Load env files specified via -e/--env flag
if len(h.EnvFiles) > 0 {
h.loadEnvFiles(h.EnvFiles)
}

err := h.parseColors(c.String("colors"))
utils.FatalOnErr(err)

Expand Down Expand Up @@ -166,3 +173,18 @@ func (h *Handler) parseStopSignals(signals string) error {

return nil
}

func (h *Handler) loadEnvFiles(envFiles string) {
envs := strings.Split(envFiles, ",")
for _, e := range envs {
e = strings.TrimSpace(e)
if len(e) > 0 {
err := godotenv.Overload(e)
if err != nil {
if !os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, "overmind: skipping %s due to error: %v\n", e, err)
}
}
}
}
}