Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 5050ac1

Browse files
authored
Added --start-timeout flag with default value of 5 minutes (#294)
1 parent 3e8f5a7 commit 5050ac1

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

cmd/dev.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ var (
5555

5656
var userDefinedHasuraCli string
5757

58-
const userDefinedHasuraCliFlag = "hasuracli"
59-
6058
const (
6159
// default ports
6260
defaultProxyPort = 1337
@@ -67,6 +65,10 @@ const (
6765
defaultSMTPPort = 1025
6866
defaultS3MinioPort = 9000
6967
defaultMailhogPort = 8025
68+
69+
// flags
70+
userDefinedHasuraCliFlag = "hasuracli"
71+
startTimeoutFlag = "start-timeout"
7072
)
7173

7274
// devCmd represents the dev command
@@ -122,6 +124,11 @@ var devCmd = &cobra.Command{
122124
return fmt.Errorf("failed to init hasura client: %v", err)
123125
}
124126

127+
startTimeout, err := cmd.Flags().GetDuration(startTimeoutFlag)
128+
if err != nil {
129+
return fmt.Errorf("failed to get start-timeout value: %v", err)
130+
}
131+
125132
launcher := service.NewLauncher(
126133
service.NewDockerComposeManager(config, hc, ports, env, nhost.GetCurrentBranch(),
127134
projectName,
@@ -138,7 +145,7 @@ var devCmd = &cobra.Command{
138145
signal.Notify(stopCh, syscall.SIGINT, syscall.SIGTERM)
139146

140147
go func() {
141-
err = launcher.Start(ctx, debug)
148+
err = launcher.Start(ctx, startTimeout, debug)
142149

143150
if ctx.Err() == context.Canceled {
144151
return
@@ -262,6 +269,7 @@ func init() {
262269
devCmd.PersistentFlags().Uint32(nhost.PortSMTP, defaultSMTPPort, "Port for smtp server")
263270
devCmd.PersistentFlags().Uint32(nhost.PortMinioS3, defaultS3MinioPort, "S3 port for minio")
264271
devCmd.PersistentFlags().Uint32(nhost.PortMailhog, defaultMailhogPort, "Port for mailhog UI")
272+
devCmd.PersistentFlags().Duration(startTimeoutFlag, 5*time.Minute, "Timeout for starting services")
265273
devCmd.PersistentFlags().BoolVar(&noBrowser, "no-browser", false, "Don't open browser windows automatically")
266274

267275
devCmd.PersistentFlags().StringVar(&userDefinedHasuraCli, userDefinedHasuraCliFlag, viper.GetString(userDefinedHasuraCliFlag), "User-defined path for hasura-cli binary")

nhost/service/launcher.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ func (l *Launcher) HasuraConsoleURL() string {
5959
return l.mgr.HasuraConsoleURL()
6060
}
6161

62-
func (l *Launcher) Start(ctx context.Context, debug bool) error {
62+
func (l *Launcher) Start(ctx context.Context, startTimeout time.Duration, debug bool) error {
63+
l.l.Debugf("start timeout is set to %s", startTimeout.String())
6364
if err := l.ensureInitialised(); err != nil {
6465
return err
6566
}
6667

67-
startCtx, cancel := context.WithTimeout(ctx, time.Minute*3)
68+
startCtx, cancel := context.WithTimeout(ctx, startTimeout)
6869
defer cancel()
6970

7071
return l.mgr.SyncExec(startCtx, func(cCtx context.Context) error {

0 commit comments

Comments
 (0)