-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #837 from rsteube/add-supervisorctl
added supervisorctl
- Loading branch information
Showing
21 changed files
with
556 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/supervisor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var addCmd = &cobra.Command{ | ||
Use: "add", | ||
Short: "Activates any updates in config for process/group", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(addCmd).Standalone() | ||
|
||
rootCmd.AddCommand(addCmd) | ||
|
||
carapace.Gen(addCmd).PositionalAnyCompletion( | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return carapace.Batch( | ||
supervisor.ActionGroups(rootCmd.Flag("configuration").Value.String()), | ||
supervisor.ActionProcesses(rootCmd.Flag("configuration").Value.String()), | ||
).ToA().Invoke(c).Filter(c.Args).ToA() | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/supervisor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var clearCmd = &cobra.Command{ | ||
Use: "clear", | ||
Short: "Clear a process’ log files", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(clearCmd).Standalone() | ||
|
||
rootCmd.AddCommand(clearCmd) | ||
|
||
carapace.Gen(clearCmd).PositionalAnyCompletion( | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return carapace.Batch( | ||
supervisor.ActionProcesses(rootCmd.Flag("configuration").Value.String()).Invoke(c).Filter(c.Args).ToA(), | ||
carapace.ActionValues("all"), | ||
).ToA() | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/supervisor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var fgCmd = &cobra.Command{ | ||
Use: "fg", | ||
Short: "Connect to a process in foreground mode Press Ctrl+C to exit foreground", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(fgCmd).Standalone() | ||
|
||
rootCmd.AddCommand(fgCmd) | ||
|
||
carapace.Gen(fgCmd).PositionalCompletion( | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return supervisor.ActionProcesses(rootCmd.Flag("configuration").Value.String()) | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var helpCmd = &cobra.Command{ | ||
Use: "help", | ||
Short: "Print help for <action>", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(helpCmd).Standalone() | ||
|
||
rootCmd.AddCommand(helpCmd) | ||
|
||
carapace.Gen(helpCmd).PositionalCompletion( | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
vals := make([]string, 0) | ||
for _, cmd := range helpCmd.Parent().Commands() { | ||
if cmd != helpCmd && !cmd.Hidden { | ||
vals = append(vals, cmd.Name(), cmd.Short) | ||
} | ||
} | ||
return carapace.ActionValuesDescribed(vals...) | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/supervisor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var pidCmd = &cobra.Command{ | ||
Use: "pid", | ||
Short: "Get the PID of supervisord", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(pidCmd).Standalone() | ||
|
||
rootCmd.AddCommand(pidCmd) | ||
|
||
carapace.Gen(pidCmd).PositionalCompletion( | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return carapace.Batch( | ||
supervisor.ActionProcesses(rootCmd.Flag("configuration").Value.String()), | ||
carapace.ActionValues("all"), | ||
).ToA() | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var reloadCmd = &cobra.Command{ | ||
Use: "reload", | ||
Short: "Restarts the remote supervisord", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(reloadCmd).Standalone() | ||
|
||
rootCmd.AddCommand(reloadCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/supervisor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var removeCmd = &cobra.Command{ | ||
Use: "remove", | ||
Short: "Activates any updates in config for process/group", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(removeCmd).Standalone() | ||
|
||
rootCmd.AddCommand(removeCmd) | ||
|
||
carapace.Gen(removeCmd).PositionalAnyCompletion( | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return carapace.Batch( | ||
supervisor.ActionGroups(rootCmd.Flag("configuration").Value.String()), | ||
supervisor.ActionProcesses(rootCmd.Flag("configuration").Value.String()), | ||
).ToA().Invoke(c).Filter(c.Args).ToA() | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rereadCmd = &cobra.Command{ | ||
Use: "reread", | ||
Short: "Reload the daemon’s configuration files, without add/remove (no restarts)", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(rereadCmd).Standalone() | ||
|
||
rootCmd.AddCommand(rereadCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/supervisor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var restartCmd = &cobra.Command{ | ||
Use: "restart", | ||
Short: "Restart a process", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(restartCmd).Standalone() | ||
|
||
rootCmd.AddCommand(restartCmd) | ||
|
||
carapace.Gen(restartCmd).PositionalAnyCompletion( | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return carapace.Batch( | ||
supervisor.ActionGroups(rootCmd.Flag("configuration").Value.String()), | ||
supervisor.ActionProcesses(rootCmd.Flag("configuration").Value.String()), | ||
carapace.ActionValues("all"), | ||
).ToA().Invoke(c).Filter(c.Args).ToA() | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "supervisorctl", | ||
Short: "control applications run by supervisord from the cmd line", | ||
Long: "http://supervisord.org/", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
rootCmd.Flags().StringP("configuration", "c", "", "configuration file path") | ||
rootCmd.Flags().BoolP("help", "h", false, "print usage message and exit") | ||
rootCmd.Flags().BoolP("history-file", "r", false, "keep a readline history") | ||
rootCmd.Flags().BoolP("interactive", "i", false, "start an interactive shell after executing commands") | ||
rootCmd.Flags().StringP("password", "p", "", "password to use for authentication with server") | ||
rootCmd.Flags().StringP("serverurl", "s", "", "URL on which supervisord server is listening") | ||
rootCmd.Flags().StringP("username", "u", "", "username to use for authentication with server") | ||
|
||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ | ||
"configuration": carapace.ActionFiles(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/supervisor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var signalCmd = &cobra.Command{ | ||
Use: "signal", | ||
Short: "Signal process", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(signalCmd).Standalone() | ||
|
||
rootCmd.AddCommand(signalCmd) | ||
|
||
carapace.Gen(signalCmd).PositionalCompletion( | ||
supervisor.ActionSignals(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/supervisor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var startCmd = &cobra.Command{ | ||
Use: "start", | ||
Short: "Start a process", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(startCmd).Standalone() | ||
|
||
rootCmd.AddCommand(startCmd) | ||
|
||
carapace.Gen(startCmd).PositionalAnyCompletion( | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return carapace.Batch( | ||
supervisor.ActionGroups(rootCmd.Flag("configuration").Value.String()), | ||
supervisor.ActionProcesses(rootCmd.Flag("configuration").Value.String()), | ||
carapace.ActionValues("all"), | ||
).ToA().Invoke(c).Filter(c.Args).ToA() | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var statusCmd = &cobra.Command{ | ||
Use: "status", | ||
Short: "Get all process status info", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(statusCmd).Standalone() | ||
|
||
rootCmd.AddCommand(statusCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/supervisor" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var stopCmd = &cobra.Command{ | ||
Use: "stop", | ||
Short: "Stop a process", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(stopCmd).Standalone() | ||
|
||
rootCmd.AddCommand(stopCmd) | ||
|
||
carapace.Gen(stopCmd).PositionalAnyCompletion( | ||
carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return carapace.Batch( | ||
supervisor.ActionGroups(rootCmd.Flag("configuration").Value.String()), | ||
supervisor.ActionProcesses(rootCmd.Flag("configuration").Value.String()), | ||
carapace.ActionValues("all"), | ||
).ToA().Invoke(c).Filter(c.Args).ToA() | ||
}), | ||
) | ||
} |
Oops, something went wrong.