mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 20:36:12 +02:00
* fix order of display of parsers * add a --no-clean opt
This commit is contained in:
parent
1e0bcedef5
commit
6ca053ca67
11 changed files with 418 additions and 381 deletions
|
@ -5,21 +5,25 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func sortedMapKeys[V any](m map[string]V) []string {
|
||||
keys := make([]string, 0, len(m))
|
||||
for k := range m {
|
||||
keys = append(keys, k)
|
||||
func IsAlive(target string) (bool, error) {
|
||||
start := time.Now()
|
||||
for {
|
||||
conn, err := net.Dial("tcp", target)
|
||||
if err == nil {
|
||||
log.Debugf("'%s' is up after %s", target, time.Since(start))
|
||||
conn.Close()
|
||||
return true, nil
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
if time.Since(start) > 10*time.Second {
|
||||
return false, fmt.Errorf("took more than 10s for %s to be available", target)
|
||||
}
|
||||
}
|
||||
|
||||
sort.Strings(keys)
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
func Copy(src string, dst string) error {
|
||||
|
@ -110,19 +114,3 @@ func CopyDir(src string, dest string) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func IsAlive(target string) (bool, error) {
|
||||
start := time.Now()
|
||||
for {
|
||||
conn, err := net.Dial("tcp", target)
|
||||
if err == nil {
|
||||
log.Debugf("'%s' is up after %s", target, time.Since(start))
|
||||
conn.Close()
|
||||
return true, nil
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
if time.Since(start) > 10*time.Second {
|
||||
return false, fmt.Errorf("took more than 10s for %s to be available", target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue