Add start api command

This commit is contained in:
yo 2024-09-05 09:34:10 +02:00
parent 372e92fc41
commit 199b3b1f7f

View File

@ -28,6 +28,9 @@ type createArgs struct {
}
var (
gApiAddress string
gApiPort int
gJailHost JailHost
gJails []Jail
gDatastores []Datastore
@ -362,6 +365,14 @@ You can specify multiple datastores.`,
},
}
apiCmd = &cobra.Command{
Use: "startapi",
Short: "Run docage as a daemon, exposing API",
Run: func(cmd *cobra.Command, args []string) {
startApi(gApiAddress, gApiPort)
},
}
testCmd = &cobra.Command{
Use: "test",
Short: "temporary command to test some code snippet",
@ -428,6 +439,9 @@ func init() {
createCmd.Flags().BoolVarP(&gCreateArgs.BaseJail, "basejail", "b", false, "Basejail. This will create a jail mounted read only from a release, so every up(date|grade) made to this release will immediately propagate to new jail.\n")
createCmd.Flags().StringVarP(&gCreateArgs.Datastore, "datastore", "d", "", "Datastore to create the jail on. Defaults to first declared in config.")
apiCmd.Flags().StringVarP(&gApiAddress, "listen-addr", "l", "127.0.0.1", "API listening address")
apiCmd.Flags().IntVarP(&gApiPort, "listen-port", "p", 1234, "API listening port")
// Now declare commands
rootCmd.AddCommand(versionCmd)
rootCmd.AddCommand(listCmd)
@ -446,6 +460,7 @@ func init() {
rootCmd.AddCommand(updateCmd)
rootCmd.AddCommand(upgradeCmd)
rootCmd.AddCommand(createCmd)
rootCmd.AddCommand(apiCmd)
rootCmd.AddCommand(testCmd)