-
Notifications
You must be signed in to change notification settings - Fork 388
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Leave cluster RPC command Implement the command to leave a cluster using an agent command and calling the leave method by RPC to the local or remote agent.
- Loading branch information
Victor Castell
authored
Feb 21, 2019
1 parent
caaf783
commit d7b1eaa
Showing
14 changed files
with
262 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/victorcoder/dkron/dkron" | ||
) | ||
|
||
var rpcAddr string | ||
|
||
// versionCmd represents the version command | ||
var leaveCmd = &cobra.Command{ | ||
Use: "leave", | ||
Short: "Force an agent to leave the cluster", | ||
Long: `Stop stops an agent, if the agent is a server and is running for election | ||
stop running for election, if this server was the leader | ||
this will force the cluster to elect a new leader and start a new scheduler. | ||
If this is a server and has the scheduler started stop it, ignoring if this server | ||
was participating in leader election or not (local storage). | ||
Then actually leave the cluster.`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
var gc dkron.DkronGRPCClient | ||
gc = dkron.NewGRPCClient(nil) | ||
|
||
if err := gc.Leave(rpcAddr); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
func init() { | ||
dkronCmd.AddCommand(leaveCmd) | ||
leaveCmd.PersistentFlags().StringVar(&rpcAddr, "rpc-addr", "127.0.0.1:6868", "gRPC address of the agent") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.