Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var InitCmd = &cobra.Command{ Use: "init", Short: "Setup Actions in Kubernetes or Standalone modes", Run: func(cmd *cobra.Command, args []string) { print.PendingStatusEvent(os.Stdout, "Making the jump to hyperspace...") if kubernetesMode { err := kubernetes.Init() if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) return } print.SuccessStatusEvent(os.Stdout, "Success! Actions is up and running. To verify, run 'kubectl get pods' in your terminal") } else { err := standalone.Init(runtimeVersion) if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) return } print.SuccessStatusEvent(os.Stdout, "Success! Actions is up and running") } }, }
View Source
var ListCmd = &cobra.Command{ Use: "list", Short: "List all Actions", Run: func(cmd *cobra.Command, args []string) { if kubernetesMode { list, err := kubernetes.List() if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(1) } table, err := gocsv.MarshalString(list) if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(1) } utils.PrintTable(table) } else { list, err := standalone.List() if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(1) } if len(list) == 0 { println("No Actions found.") return } table, err := gocsv.MarshalString(list) if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(1) } utils.PrintTable(table) } }, }
View Source
var PublishCmd = &cobra.Command{ Use: "publish", Short: "publish an event to multiple consumers", Run: func(cmd *cobra.Command, args []string) { err := publish.PublishTopic(publishTopic, publishPayload) if err != nil { print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error publishing topic %s: %s", publishTopic, err)) return } print.SuccessStatusEvent(os.Stdout, "Event published successfully") }, }
View Source
var RootCmd = &cobra.Command{
Use: "actions",
Short: "Actions CLI",
Long: `
___ ___________________ _ ______
/ _ |/ ___/_ __/ _/ __ \/ |/ / __/
/ __ / /__ / / _/ // /_/ / /\ \
/_/ |_\___/ /_/ /___/\____/_/|_/___/
======================================================
A serverless runtime for hyperscale, distributed systems`,
}
View Source
var RunCmd = &cobra.Command{ Use: "run", Short: "Launches Actions and your app side by side", Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { uuid, err := uuid.NewRandom() if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) return } actionsRunID := uuid.String() if kubernetesMode { output, err := kubernetes.Run(&kubernetes.RunConfig{ AppID: appID, AppPort: appPort, Port: port, Arguments: args, Image: image, CodeDirectory: args[0], }) if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) return } print.InfoStatusEvent(os.Stdout, output.Message) } else { output, err := standalone.Run(&standalone.RunConfig{ AppID: appID, AppPort: appPort, Port: port, ConfigFile: configFile, Arguments: args, EnableProfiling: enableProfiling, ProfilePort: profilePort, LogLevel: logLevel, }) if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) return } var sigCh = make(chan os.Signal) signal.Notify(sigCh, syscall.SIGTERM, syscall.SIGINT) actionsRunning := make(chan bool, 1) appRunning := make(chan bool, 1) actionsRunCreatedTime := time.Now() go func() { print.InfoStatusEvent(os.Stdout, fmt.Sprintf("Starting Actions with id %s on port %v", output.AppID, output.ActionsPort)) stdErrPipe, err := output.ActionsCMD.StderrPipe() if err != nil { print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error creating stderr for Actions: %s", err.Error())) os.Exit(1) } stdOutPipe, err := output.ActionsCMD.StdoutPipe() if err != nil { print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error creating stdout for Actions: %s", err.Error())) os.Exit(1) } errScanner := bufio.NewScanner(stdErrPipe) outScanner := bufio.NewScanner(stdOutPipe) go func() { for errScanner.Scan() { fmt.Printf(print.Yellow(fmt.Sprintf("== ACTIONS == %s\n", errScanner.Text()))) } }() go func() { for outScanner.Scan() { fmt.Printf(print.Yellow(fmt.Sprintf("== ACTIONS == %s\n", outScanner.Text()))) } }() err = output.ActionsCMD.Start() if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(1) } actionsRunning <- true }() <-actionsRunning go func() { stdErrPipe, err := output.AppCMD.StderrPipe() if err != nil { print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error creating stderr for App: %s", err.Error())) os.Exit(1) } stdOutPipe, err := output.AppCMD.StdoutPipe() if err != nil { print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error creating stdout for App: %s", err.Error())) os.Exit(1) } errScanner := bufio.NewScanner(stdErrPipe) outScanner := bufio.NewScanner(stdOutPipe) go func() { for errScanner.Scan() { fmt.Printf(print.Blue(fmt.Sprintf("== APP == %s\n", errScanner.Text()))) } }() go func() { for outScanner.Scan() { fmt.Printf(print.Blue(fmt.Sprintf("== APP == %s\n", outScanner.Text()))) } }() err = output.AppCMD.Start() if err != nil { print.FailureStatusEvent(os.Stdout, err.Error()) os.Exit(1) } appRunning <- true }() <-appRunning rundata.AppendRunData(&rundata.RunData{ ActionsRunId: actionsRunID, AppId: output.AppID, ActionsPort: output.ActionsPort, AppPort: appPort, Command: strings.Join(args, " "), Created: actionsRunCreatedTime, PID: os.Getpid(), }) print.SuccessStatusEvent(os.Stdout, "You're up and running! Both Actions and your app logs will appear here.\n") <-sigCh print.InfoStatusEvent(os.Stdout, "\nterminated signal recieved: shutting down") rundata.ClearRunData(actionsRunID) err = output.ActionsCMD.Process.Kill() if err != nil { print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error exiting Actions: %s", err)) } else { print.SuccessStatusEvent(os.Stdout, "Exited Actions successfully") } err = output.AppCMD.Process.Kill() if err != nil { print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error exiting App: %s", err)) } else { print.SuccessStatusEvent(os.Stdout, "Exited App successfully") } } }, }
View Source
var SendCmd = &cobra.Command{ Use: "send", Short: "invoke an Actions app or actor with an optional payload", Run: func(cmd *cobra.Command, args []string) { response, err := send.InvokeApp(sendAppID, sendAppMethod, sendPayload) if err != nil { print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error invoking app %s: %s", sendAppID, err)) return } if response != "" { fmt.Println(response) } print.SuccessStatusEvent(os.Stdout, "App invoked successfully") }, }
View Source
var StopCmd = &cobra.Command{ Use: "stop", Short: "Stops a running Actions instance and its associated app", Run: func(cmd *cobra.Command, args []string) { err := standalone.Stop(stopAppID) if err != nil { print.FailureStatusEvent(os.Stdout, "failed to stop app id %s: %s", stopAppID, err) } else { print.SuccessStatusEvent(os.Stdout, "app stopped successfully") } }, }
View Source
var UninstallCmd = &cobra.Command{ Use: "uninstall", Short: "removes an Actions installation", Run: func(cmd *cobra.Command, args []string) { print.InfoStatusEvent(os.Stdout, "Removing Actions from your cluster...") err := kubernetes.Uninstall() if err != nil { print.FailureStatusEvent(os.Stdout, fmt.Sprintf("Error removing Actions: %s", err)) return } print.SuccessStatusEvent(os.Stdout, "Actions has been removed successfully") }, }
UninstallCmd is a command from removing an Actions installation
Functions ¶
Types ¶
This section is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.