mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-29 02:21:12 +02:00
This provides a bit better handling for the handing grpc requests (or just slow requests): ``` $ osctl-linux-amd64 --talosconfig talosconfig version Client: Tag: ad410fb-dirty SHA: ad410fb-dirty Built: Go version: go1.12.5 OS/Arch: linux/amd64 ^CSignal received, aborting, press Ctrl+C once again to abort immediately... error getting version: rpc error: code = Canceled desc = context canceled ``` For now we catch `SIGINT` & `SIGTERM`. Second signal kills process immediately as signal handler is removed. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
42 lines
978 B
Go
42 lines
978 B
Go
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/talos-systems/talos/cmd/osctl/pkg/client"
|
|
"github.com/talos-systems/talos/cmd/osctl/pkg/helpers"
|
|
)
|
|
|
|
// dmesgCmd represents the dmesg command
|
|
var dmesgCmd = &cobra.Command{
|
|
Use: "dmesg",
|
|
Short: "Retrieve kernel logs",
|
|
Long: ``,
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
if len(args) != 0 {
|
|
helpers.Should(cmd.Usage())
|
|
os.Exit(1)
|
|
}
|
|
|
|
setupClient(func(c *client.Client) {
|
|
msg, err := c.Dmesg(globalCtx)
|
|
if err != nil {
|
|
helpers.Fatalf("error getting dmesg: %s", err)
|
|
}
|
|
|
|
_, err = os.Stdout.Write(msg)
|
|
helpers.Should(err)
|
|
})
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
dmesgCmd.Flags().StringVarP(&target, "target", "t", "", "target the specificed node")
|
|
rootCmd.AddCommand(dmesgCmd)
|
|
}
|