diff --git a/cmd/daemon/run-server.go b/cmd/daemon/run-server.go index f161672..7878f9a 100644 --- a/cmd/daemon/run-server.go +++ b/cmd/daemon/run-server.go @@ -4,6 +4,7 @@ import ( "net/http" "os" "strconv" + "time" "github.com/curusarn/resh/internal/cfg" "github.com/curusarn/resh/internal/histfile" @@ -67,8 +68,12 @@ func (s *Server) Run() { mux.Handle("/dump", &dumpHandler{sugar: s.sugar, histfileBox: histfileBox}) server := &http.Server{ - Addr: "localhost:" + strconv.Itoa(s.config.Port), - Handler: mux, + Addr: "localhost:" + strconv.Itoa(s.config.Port), + Handler: mux, + ReadTimeout: 1 * time.Second, + WriteTimeout: 1 * time.Second, + ReadHeaderTimeout: 1 * time.Second, + IdleTimeout: 30 * time.Second, } go server.ListenAndServe() diff --git a/internal/collect/collect.go b/internal/collect/collect.go index 179859a..a72825c 100644 --- a/internal/collect/collect.go +++ b/internal/collect/collect.go @@ -8,8 +8,8 @@ import ( "path/filepath" "strconv" "strings" + "time" - "github.com/curusarn/resh/internal/httpclient" "github.com/curusarn/resh/internal/output" "github.com/curusarn/resh/internal/records" "go.uber.org/zap" @@ -39,7 +39,9 @@ func SendRecord(out *output.Output, r records.Record, port, path string) { } req.Header.Set("Content-Type", "application/json") - client := httpclient.New() + client := http.Client{ + Timeout: 1 * time.Second, + } _, err = client.Do(req) if err != nil { out.FatalDaemonNotRunning(err) diff --git a/scripts/util.sh b/scripts/util.sh index f2e2754..b434ecc 100644 --- a/scripts/util.sh +++ b/scripts/util.sh @@ -172,16 +172,6 @@ __resh_session_init() { } __resh_set_xdg_home_paths() { - if [ -z "${XDG_CONFIG_HOME-}" ]; then - __RESH_XDG_CONFIG_FILE="$HOME/.config" - else - __RESH_XDG_CONFIG_FILE="$XDG_CONFIG_HOME" - fi - mkdir -p "$__RESH_XDG_CONFIG_FILE" >/dev/null 2>/dev/null - __RESH_XDG_CONFIG_FILE="$__RESH_XDG_CONFIG_FILE/resh.toml" - export __RESH_XDG_CONFIG_FILE - - if [ -z "${XDG_CACHE_HOME-}" ]; then __RESH_XDG_CACHE_HOME="$HOME/.cache/resh" else @@ -197,5 +187,5 @@ __resh_set_xdg_home_paths() { __RESH_XDG_DATA_HOME="$XDG_DATA_HOME/resh" fi mkdir -p "$__RESH_XDG_DATA_HOME" >/dev/null 2>/dev/null - export __RESH_XDG_CONFIG_FILE + export __RESH_XDG_DATA_HOME }