From b8ed722b2eb16d2107965e377f819eae8d7affe4 Mon Sep 17 00:00:00 2001 From: Umputun Date: Mon, 24 Dec 2018 00:19:12 -0600 Subject: [PATCH] increase wrtie timeout to allow long exports --- backend/app/cmd/backup.go | 2 +- backend/app/migrator/native.go | 2 +- backend/app/rest/api/rest.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/app/cmd/backup.go b/backend/app/cmd/backup.go index 3a41944e..584dab33 100644 --- a/backend/app/cmd/backup.go +++ b/backend/app/cmd/backup.go @@ -18,7 +18,7 @@ type BackupCommand struct { ExportPath string `short:"p" long:"path" env:"BACKUP_PATH" default:"./var/backup" description:"export path"` ExportFile string `short:"f" long:"file" default:"userbackup-{{.SITE}}-{{.TS}}.gz" description:"file name"` Site string `short:"s" long:"site" env:"SITE" default:"remark" description:"site name"` - Timeout time.Duration `long:"timeout" default:"15m" description:"import timeout"` + Timeout time.Duration `long:"timeout" default:"15m" description:"export (backup) timeout"` CommonOpts } diff --git a/backend/app/migrator/native.go b/backend/app/migrator/native.go index abb06eb2..79a5b342 100644 --- a/backend/app/migrator/native.go +++ b/backend/app/migrator/native.go @@ -91,7 +91,7 @@ func (n *Native) Import(reader io.Reader, siteID string) (size int, err error) { return 0, errors.Wrapf(err, "failed to import meta for site %s", siteID) } - if m.Version != natvieVersion { + if m.Version != natvieVersion && m.Version != 0 { // this version allows back compatibility with 0 version return 0, errors.Errorf("unexpected import file version %d", m.Version) } diff --git a/backend/app/rest/api/rest.go b/backend/app/rest/api/rest.go index 74ba5afe..37845468 100644 --- a/backend/app/rest/api/rest.go +++ b/backend/app/rest/api/rest.go @@ -147,7 +147,7 @@ func (s *Rest) makeHTTPServer(port int, router http.Handler) *http.Server { Addr: fmt.Sprintf(":%d", port), Handler: router, ReadHeaderTimeout: 5 * time.Second, - WriteTimeout: 5 * time.Second, + WriteTimeout: 120 * time.Second, // TODO: such a long timeout needed for blocking export (backup) request IdleTimeout: 30 * time.Second, } }