mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-02 00:57:45 +00:00
fix lint issue
This commit is contained in:
parent
a2e0e013e5
commit
99aff8d513
@ -44,8 +44,10 @@ func init() {
|
|||||||
func runConsoleWithoutProxy() {
|
func runConsoleWithoutProxy() {
|
||||||
log.Info().Msg("Starting scripting console ...")
|
log.Info().Msg("Starting scripting console ...")
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
|
hubUrl := kubernetes.GetHubUrl()
|
||||||
for {
|
for {
|
||||||
hubUrl := kubernetes.GetHubUrl()
|
|
||||||
|
// Attempt to connect to the Hub every second
|
||||||
response, err := http.Get(fmt.Sprintf("%s/echo", hubUrl))
|
response, err := http.Get(fmt.Sprintf("%s/echo", hubUrl))
|
||||||
if err != nil || response.StatusCode != 200 {
|
if err != nil || response.StatusCode != 200 {
|
||||||
log.Info().Msg(fmt.Sprintf(utils.Yellow, "Couldn't connect to Hub."))
|
log.Info().Msg(fmt.Sprintf(utils.Yellow, "Couldn't connect to Hub."))
|
||||||
@ -121,29 +123,34 @@ func runConsoleWithoutProxy() {
|
|||||||
|
|
||||||
func runConsole() {
|
func runConsole() {
|
||||||
go runConsoleWithoutProxy()
|
go runConsoleWithoutProxy()
|
||||||
|
|
||||||
|
// Create interrupt channel and setup signal handling once
|
||||||
|
interrupt := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(interrupt, os.Interrupt)
|
||||||
|
done := make(chan struct{})
|
||||||
|
|
||||||
|
ticker := time.NewTicker(5 * time.Second)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
hubUrl := kubernetes.GetHubUrl()
|
select {
|
||||||
response, err := http.Get(fmt.Sprintf("%s/echo", hubUrl))
|
|
||||||
if err != nil || response.StatusCode != 200 {
|
|
||||||
log.Info().Msg(fmt.Sprintf(utils.Yellow, "Couldn't connect to Hub. Establishing proxy..."))
|
|
||||||
runProxy(false, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
interrupt := make(chan os.Signal, 1)
|
|
||||||
signal.Notify(interrupt, os.Interrupt)
|
|
||||||
done := make(chan struct{})
|
|
||||||
|
|
||||||
ticker := time.NewTicker(time.Second)
|
|
||||||
defer ticker.Stop()
|
|
||||||
|
|
||||||
select { // Reconnect after error
|
|
||||||
case <-interrupt:
|
case <-interrupt:
|
||||||
|
// Handle interrupt and exit gracefully
|
||||||
log.Warn().Msg(fmt.Sprintf(utils.Yellow, "Received interrupt, exiting..."))
|
log.Warn().Msg(fmt.Sprintf(utils.Yellow, "Received interrupt, exiting..."))
|
||||||
select {
|
select {
|
||||||
case <-done:
|
case <-done:
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
||||||
|
case <-ticker.C:
|
||||||
|
// Attempt to connect to the Hub every second
|
||||||
|
hubUrl := kubernetes.GetHubUrl()
|
||||||
|
response, err := http.Get(fmt.Sprintf("%s/echo", hubUrl))
|
||||||
|
if err != nil || response.StatusCode != 200 {
|
||||||
|
log.Info().Msg(fmt.Sprintf(utils.Yellow, "Couldn't connect to Hub. Establishing proxy..."))
|
||||||
|
runProxy(false, true)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user