-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement process entrypoint and run cmd
### process entrypoint `entrypoint` is an optional array of strings which can be set on the process config to override default shell (and shellArg) used to run the `command` When `entrypoint` is set and is non-empty, `command` can also be omitted. This is useful if one want's to: 1. use a different shell per process 2. run any other executable directly, without a shell wrapper ### `run` cmd Equivalent of [docker-compose run](https://docs.docker.com/engine/reference/commandline/compose_run/) which can be used to run a chosen process in the foreground (with std(in|out|err) attached), while it's dependencies are ran in the background (no logs printed to stdio). Deps can be disabled via --no-deps flag. Additional arguments can be passed to the process after `--` separator, for example: ```sh process-compose run main -- arg1 arg2 ``` The separator is necessary in order to distinguish process-compose flags from flags meant to be passed to the process. While the process is running, the logs of the deps can be inspected using the usual command: ``` process-compose process logs dep ``` The process being ran will have `availability.exit_on_end` set to `true` and manually setting it to `false` will have no effect.
- Loading branch information
1 parent
5d7d23d
commit 29dba80
Showing
13 changed files
with
196 additions
and
33 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 |
---|---|---|
|
@@ -15,4 +15,5 @@ type Commander interface { | |
StderrPipe() (io.ReadCloser, error) | ||
Stop(int, bool) error | ||
SetCmdArgs() | ||
AttachIo() | ||
} |
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
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
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
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
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
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,54 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"github.com/f1bonacc1/process-compose/src/api" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// runCmd represents the up command | ||
var runCmd = &cobra.Command{ | ||
Use: "run PROCESS [flags] -- [process_args]", | ||
Short: "Run PROCESS in the foreground, and it's dependencies in the background", | ||
Long: `Run selected process with std(in|out|err) attached, while other processes run in the background. | ||
Command line arguments, provided after --, are passed to the PROCESS.`, | ||
Args: cobra.MinimumNArgs(1), | ||
// Args: cobra.ExactArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
*pcFlags.Headless = false | ||
|
||
processName := args[0] | ||
|
||
if len(args) > 1 { | ||
argsLenAtDash := cmd.ArgsLenAtDash() | ||
if argsLenAtDash != 1 { | ||
message := "Extra positional arguments provided! To pass args to PROCESS, separate them from process-compose arguments with: --" | ||
fmt.Println(message) | ||
os.Exit(1) | ||
} | ||
args = args[argsLenAtDash:] | ||
} else { | ||
// Clease args as they will contain the processName | ||
args = []string{} | ||
} | ||
|
||
runner := getProjectRunner( | ||
[]string{processName}, | ||
*pcFlags.NoDependencies, | ||
processName, | ||
args, | ||
) | ||
|
||
api.StartHttpServer(false, *pcFlags.PortNum, runner) | ||
runProject(runner) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(runCmd) | ||
|
||
runCmd.Flags().BoolVarP(pcFlags.NoDependencies, "no-deps", "", *pcFlags.NoDependencies, "don't start dependent processes") | ||
runCmd.Flags().AddFlag(rootCmd.Flags().Lookup("config")) | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.