mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-04-29 14:09:54 -05:00
fix(engine): add --no-graceful-shutdown flag for nodemon (#221)
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"context"
|
||||
|
||||
"github.com/hatchet-dev/hatchet/cmd/hatchet-engine/engine"
|
||||
"github.com/hatchet-dev/hatchet/internal/config/loader"
|
||||
"github.com/hatchet-dev/hatchet/pkg/cmdutils"
|
||||
@@ -14,6 +16,7 @@ import (
|
||||
|
||||
var printVersion bool
|
||||
var configDirectory string
|
||||
var noGracefulShutdown bool
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
@@ -22,12 +25,18 @@ var rootCmd = &cobra.Command{
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
if printVersion {
|
||||
fmt.Println(Version)
|
||||
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
cf := loader.NewConfigLoader(configDirectory)
|
||||
context, cancel := cmdutils.NewInterruptContext()
|
||||
defer cancel()
|
||||
|
||||
context := context.Background()
|
||||
if !noGracefulShutdown {
|
||||
ctx, cancel := cmdutils.NewInterruptContext()
|
||||
defer cancel()
|
||||
context = ctx
|
||||
}
|
||||
|
||||
if err := engine.Run(context, cf); err != nil {
|
||||
log.Printf("engine failure: %s", err.Error())
|
||||
@@ -54,6 +63,13 @@ func main() {
|
||||
"The path the config folder.",
|
||||
)
|
||||
|
||||
rootCmd.PersistentFlags().BoolVar(
|
||||
&noGracefulShutdown,
|
||||
"no-graceful-shutdown",
|
||||
false,
|
||||
"Whether not to shut down gracefully (useful for nodemon/air).",
|
||||
)
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
|
||||
@@ -6,4 +6,4 @@ set -a
|
||||
. .env
|
||||
set +a
|
||||
|
||||
npx --yes nodemon --signal SIGINT --config nodemon.engine.json --exec go run ./cmd/hatchet-engine
|
||||
npx --yes nodemon --signal SIGINT --config nodemon.engine.json --exec go run ./cmd/hatchet-engine --no-graceful-shutdown
|
||||
|
||||
Reference in New Issue
Block a user