8000 fix(engine): add --no-graceful-shutdown flag for nodemon by steebchen · Pull Request #221 · hatchet-dev/hatchet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(engine): add --no-graceful-shutdown flag for nodemon #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions cmd/hatchet-engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ 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"
)

var printVersion bool
var configDirectory string
var noGracefulShutdown bool

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Expand All @@ -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())
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion hack/dev/start-engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
0