mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-27 19:04:28 +01:00
b2c6e51a43
This was merged to master prematurely as the job components are not decoupled well enough
for these signals to be useful yet.
This reverts commit 2c8c2cfa14
.
closes #452
43 lines
884 B
Go
43 lines
884 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/zrepl/zrepl/cli"
|
|
"github.com/zrepl/zrepl/config"
|
|
"github.com/zrepl/zrepl/daemon"
|
|
)
|
|
|
|
var SignalCmd = &cli.Subcommand{
|
|
Use: "signal [wakeup|reset] JOB",
|
|
Short: "wake up a job from wait state or abort its current invocation",
|
|
Run: func(ctx context.Context, subcommand *cli.Subcommand, args []string) error {
|
|
return runSignalCmd(subcommand.Config(), args)
|
|
},
|
|
}
|
|
|
|
func runSignalCmd(config *config.Config, args []string) error {
|
|
if len(args) != 2 {
|
|
return errors.Errorf("Expected 2 arguments: [wakeup|reset] JOB")
|
|
}
|
|
|
|
httpc, err := controlHttpClient(config.Global.Control.SockPath)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
err = jsonRequestResponse(httpc, daemon.ControlJobEndpointSignal,
|
|
struct {
|
|
Name string
|
|
Op string
|
|
}{
|
|
Name: args[1],
|
|
Op: args[0],
|
|
},
|
|
struct{}{},
|
|
)
|
|
return err
|
|
}
|