mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-05 16:19:43 -06:00
* feat: check security service * feat: propegate version * feat: with ident * fix: lint * chore: generate * fix: change domain * fix: panic recover * fix: migrations * fix: hash * fix: dont check in tests
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/hatchet-dev/hatchet/cmd/hatchet-api/api"
|
|
"github.com/hatchet-dev/hatchet/pkg/cmdutils"
|
|
"github.com/hatchet-dev/hatchet/pkg/config/loader"
|
|
)
|
|
|
|
var printVersion bool
|
|
var configDirectory string
|
|
|
|
// rootCmd represents the base command when called without any subcommands
|
|
var rootCmd = &cobra.Command{
|
|
Use: "hatchet-api",
|
|
Short: "hatchet-api runs a Hatchet instance.",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if printVersion {
|
|
fmt.Println(Version)
|
|
os.Exit(0)
|
|
}
|
|
|
|
cf := loader.NewConfigLoader(configDirectory)
|
|
interruptChan := cmdutils.InterruptChan()
|
|
|
|
if err := api.Start(cf, interruptChan, Version); err != nil {
|
|
log.Println("error starting API:", err)
|
|
os.Exit(1)
|
|
}
|
|
},
|
|
}
|
|
|
|
// Version will be linked by an ldflag during build
|
|
var Version = "v0.1.0-alpha.0"
|
|
|
|
func main() {
|
|
rootCmd.PersistentFlags().BoolVar(
|
|
&printVersion,
|
|
"version",
|
|
false,
|
|
"print version and exit.",
|
|
)
|
|
|
|
rootCmd.PersistentFlags().StringVar(
|
|
&configDirectory,
|
|
"config",
|
|
"",
|
|
"The path the config folder.",
|
|
)
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|