2018-08-29 19:17:45 +02:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
2020-04-11 15:49:41 +02:00
|
|
|
"context"
|
|
|
|
|
2018-08-29 19:17:45 +02:00
|
|
|
"github.com/pkg/errors"
|
2019-03-22 19:41:12 +01:00
|
|
|
|
2024-10-18 19:21:17 +02:00
|
|
|
"github.com/zrepl/zrepl/internal/cli"
|
|
|
|
"github.com/zrepl/zrepl/internal/config"
|
|
|
|
"github.com/zrepl/zrepl/internal/daemon"
|
2018-08-29 19:17:45 +02:00
|
|
|
)
|
|
|
|
|
2018-10-13 15:07:50 +02:00
|
|
|
var SignalCmd = &cli.Subcommand{
|
2021-03-23 18:01:12 +01:00
|
|
|
Use: "signal [wakeup|reset] JOB",
|
|
|
|
Short: "wake up a job from wait state or abort its current invocation",
|
2020-04-11 15:49:41 +02:00
|
|
|
Run: func(ctx context.Context, subcommand *cli.Subcommand, args []string) error {
|
2018-10-13 15:07:50 +02:00
|
|
|
return runSignalCmd(subcommand.Config(), args)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func runSignalCmd(config *config.Config, args []string) error {
|
2018-10-12 20:50:30 +02:00
|
|
|
if len(args) != 2 {
|
2021-03-23 18:01:12 +01:00
|
|
|
return errors.Errorf("Expected 2 arguments: [wakeup|reset] JOB")
|
2018-08-29 19:17:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
httpc, err := controlHttpClient(config.Global.Control.SockPath)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2018-10-12 20:50:30 +02:00
|
|
|
err = jsonRequestResponse(httpc, daemon.ControlJobEndpointSignal,
|
2018-08-29 19:17:45 +02:00
|
|
|
struct {
|
|
|
|
Name string
|
2019-03-22 19:41:12 +01:00
|
|
|
Op string
|
2018-08-29 19:17:45 +02:00
|
|
|
}{
|
2018-10-12 20:50:30 +02:00
|
|
|
Name: args[1],
|
2019-03-22 19:41:12 +01:00
|
|
|
Op: args[0],
|
2018-08-29 19:17:45 +02:00
|
|
|
},
|
|
|
|
struct{}{},
|
|
|
|
)
|
|
|
|
return err
|
|
|
|
}
|