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 @@ -61,6 +61,7 @@ func setupStartCmd() cli.Command {
cli.BoolFlag{Name: "daemonize, D", EnvVar: "OVERMIND_DAEMONIZE", Usage: "Launch Overmind as a daemon. Use 'overmind echo' to view logs and 'overmind quit' to gracefully quit daemonized instance", Destination: &c.Daemonize},
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: "delayed-processes, X", EnvVar: "OVERMIND_DELAYED_PROCESSES", Usage: "Specify process names to prevent from launching right now. Useful if you want to run one or two processes later. Divide names with comma. Takes precedence over the 'processes' flag.", Destination: &c.DelayedProcNames},
cli.StringFlag{Name: "shell, H", EnvVar: "OVERMIND_SHELL", Usage: "Specify shell to run processes with.", Value: "sh", Destination: &c.Shell},
},
socketFlags(&c.SocketPath, &c.Network)...,
Expand Down
14 changes: 13 additions & 1 deletion start/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func newCommand(h *Handler) (*command, error) {

procNames := utils.SplitAndTrim(h.ProcNames)
ignoredProcNames := utils.SplitAndTrim(h.IgnoredProcNames)
delayedProcNames := utils.SplitAndTrim(h.DelayedProcNames)

colors := defaultColors
if len(h.Colors) > 0 {
Expand All @@ -80,9 +81,18 @@ func newCommand(h *Handler) (*command, error) {
c.scriptDir = filepath.Join(os.TempDir(), instanceID)
os.MkdirAll(c.scriptDir, 0700)

delayedScriptFilePath := c.createScriptFile(&procfileEntry{
Name: "delayed",
OrigName: "delayed",
Command: ":",
Port: 0,
StopSignal: syscall.SIGINT,
}, h.Shell, !h.NoPort)

for i, e := range pf {
shouldRun := len(procNames) == 0 || utils.StringsContain(procNames, e.OrigName)
isIgnored := len(ignoredProcNames) != 0 && utils.StringsContain(ignoredProcNames, e.OrigName)
isDelayed := len(delayedProcNames) != 0 && utils.StringsContain(delayedProcNames, e.OrigName)

if shouldRun && !isIgnored {
scriptFilePath := c.createScriptFile(&e, h.Shell, !h.NoPort)
Expand All @@ -92,8 +102,10 @@ func newCommand(h *Handler) (*command, error) {
e.Name,
colors[i%len(colors)],
scriptFilePath,
delayedScriptFilePath,
c.output,
(h.AnyCanDie || utils.StringsContain(canDie, e.OrigName)),
isDelayed,
(h.AnyCanDie || utils.StringsContain(canDie, e.OrigName) || isDelayed),
(utils.StringsContain(autoRestart, e.OrigName) || utils.StringsContain(autoRestart, "all")),
e.StopSignal,
))
Expand Down
1 change: 1 addition & 0 deletions start/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Handler struct {
PortBase, PortStep int
ProcNames string
IgnoredProcNames string
DelayedProcNames string
SocketPath string
Network string
CanDie string
Expand Down
18 changes: 11 additions & 7 deletions start/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type process struct {
pid int

stopSignal syscall.Signal
delayed bool
canDie bool
canDieNow bool
autoRestart bool
Expand All @@ -32,29 +33,32 @@ type process struct {
in io.Writer
out io.ReadCloser

Name string
Color int
Command string
Name string
Color int
Command string
DelayedCommand string
}

func newProcess(tmux *tmuxClient, name string, color int, command string, output *multiOutput, canDie bool, autoRestart bool, stopSignal syscall.Signal) *process {
func newProcess(tmux *tmuxClient, name string, color int, command string, delayedCommand string, output *multiOutput, delayed bool, canDie bool, autoRestart bool, stopSignal syscall.Signal) *process {
out, in := io.Pipe()

proc := &process{
output: output,
tmux: tmux,

stopSignal: stopSignal,
delayed: delayed,
canDie: canDie,
canDieNow: canDie,
autoRestart: autoRestart,

in: in,
out: out,

Name: name,
Color: color,
Command: command,
Name: name,
Color: color,
Command: command,
DelayedCommand: delayedCommand,
}

tmux.AddProcess(proc)
Expand Down
11 changes: 9 additions & 2 deletions start/tmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,17 @@ func (t *tmuxClient) Start() error {
for _, p := range t.processes {
tmuxPaneMsg := fmt.Sprintf(tmuxPaneMsgFmt, p.Name)

var command string
if p.delayed {
command = p.DelayedCommand
} else {
command = p.Command
}

if first {
first = false

args = append(args, "new", "-n", p.Name, "-s", t.Session, "-P", "-F", tmuxPaneMsg, p.Command, ";")
args = append(args, "new", "-n", p.Name, "-s", t.Session, "-P", "-F", tmuxPaneMsg, command, ";")

if w, h, err := term.GetSize(int(os.Stdin.Fd())); err == nil {
if w > t.outputOffset {
Expand All @@ -95,7 +102,7 @@ func (t *tmuxClient) Start() error {
args = append(args, "setw", "-g", "remain-on-exit", "on", ";")
args = append(args, "setw", "-g", "allow-rename", "off", ";")
} else {
args = append(args, "neww", "-n", p.Name, "-P", "-F", tmuxPaneMsg, p.Command, ";")
args = append(args, "neww", "-n", p.Name, "-P", "-F", tmuxPaneMsg, command, ";")
}
}

Expand Down