Skip to content
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ GLOBAL OPTIONS:

worker

--worker-send-timeout value the timeout for a single message send operation. (default: 30s) [$FUNCTION_WORKER_SEND_TIMEOUT]
--worker-stop-timeout value the duration to wait for a worker process to stop. (default: 5s) [$FUNCTION_WORKER_STOP_TIMEOUT]
--worker-send-timeout value the timeout for a single message send operation. (default: 30s) [$FUNCTION_WORKER_SEND_TIMEOUT]
--worker-start-timeout value the duration to wait for the application to start (worker process boot + first successful RPC dial). (default: 15s) [$FUNCTION_WORKER_START_TIMEOUT]
--worker-stop-timeout value the duration to wait for a worker process to stop. (default: 5s) [$FUNCTION_WORKER_STOP_TIMEOUT]
```

## Evaluation Runtime Interface
Expand Down
2 changes: 1 addition & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ func New(ctx *cli.Context) (*shell.Shell, error) {
runtime.Module(config.Runtime),
)

return shell.New(log, appModule), nil
return shell.New(log, config.StartTimeout, appModule), nil
}
8 changes: 8 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ functions on arbitrary, serverless platforms.`
Category: "worker",
EnvVars: []string{"FUNCTION_WORKER_SEND_TIMEOUT"},
},
&cli.DurationFlag{
Name: "worker-start-timeout",
Usage: "the duration to wait for the application to start (worker process boot + first successful RPC dial).",
Value: 15 * time.Second,
Category: "worker",
EnvVars: []string{"FUNCTION_WORKER_START_TIMEOUT"},
},
&cli.StringFlag{
Name: "rpc-transport",
Aliases: []string{"t"},
Expand Down Expand Up @@ -331,6 +338,7 @@ func parseRootConfig(ctx *cli.Context) (config.Config, error) {
"rpc-transport-tcp-address": "runtime.io.rpc.tcp.address",
"worker-send-timeout": "runtime.send.timeout",
"worker-stop-timeout": "runtime.stop.timeout",
"worker-start-timeout": "start_timeout",
// sandbox
"sandbox": "runtime.sandbox.enabled",
"sandbox-nsjail-path": "runtime.sandbox.nsjail_path",
Expand Down
9 changes: 8 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package config

import "github.com/lambda-feedback/shimmy/runtime"
import (
"time"

"github.com/lambda-feedback/shimmy/runtime"
)

type MessageEncoding string

Expand All @@ -25,4 +29,7 @@ type Config struct {

// Auth is the authentication configuration
Auth AuthConfig `conf:"auth"`

// StartTimeout is the duration to wait for the application to start.
StartTimeout time.Duration `conf:"start_timeout"`
}
4 changes: 3 additions & 1 deletion internal/execution/supervisor/adapter_rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ func (a *rpcAdapter) dialRpcWithRetry(
) error {
var err error
for i := 0; ; i++ {
if client, err := a.dialRpc(ctx, a.config); err == nil {
var client *rpc.Client
client, err = a.dialRpc(ctx, a.config)
if err == nil {
a.rpcClient = client
return nil
}
Expand Down
22 changes: 14 additions & 8 deletions internal/shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@ package shell

import (
"context"
"time"

"go.uber.org/fx"
"go.uber.org/fx/fxevent"
"go.uber.org/zap"
)

type Shell struct {
log *zap.Logger
fxApp *fx.App
options []fx.Option
log *zap.Logger
fxApp *fx.App
startTimeout time.Duration
options []fx.Option
}

func New(log *zap.Logger, options ...fx.Option) *Shell {
func New(log *zap.Logger, startTimeout time.Duration, options ...fx.Option) *Shell {
return &Shell{
log: log,
options: options,
log: log,
startTimeout: startTimeout,
options: options,
}
}

Expand Down Expand Up @@ -80,10 +83,13 @@ func (s *Shell) createFxApp(ctx context.Context, options ...fx.Option) *fx.App {
return &fxevent.ZapLogger{Logger: s.log.Named("fx")}
}),

// 5. provide user-provided options
// 5. configure the application start timeout
fx.StartTimeout(s.startTimeout),

// 6. provide user-provided options
fx.Options(s.options...),

// 5. provide user-provided run options
// 7. provide user-provided run options
fx.Options(options...),
)
}
Loading