Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release file lock on USR1 signal #2151

Merged
merged 2 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cmd/common/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
package common

import (
"io"
"os"

"github.com/6543/logfile-open"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -55,14 +57,14 @@ func SetupGlobalLogger(c *cli.Context) {
noColor := c.Bool("nocolor")
logFile := c.String("log-file")

var file *os.File
var file io.ReadWriteCloser
switch logFile {
case "", "stderr": // default case
file = os.Stderr
case "stdout":
file = os.Stdout
default: // a file was set
openFile, err := os.OpenFile(logFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0o660)
openFile, err := logfile.OpenFileWithContext(c.Context, logFile, 0o660)
if err != nil {
log.Fatal().Err(err).Msgf("could not open log file '%s'", logFile)
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
code.gitea.io/sdk/gitea v0.15.1-0.20221016183512-2d9ee57af1e0
codeberg.org/6543/go-yaml2json v1.0.0
codeberg.org/6543/xyaml v1.1.0
github.com/6543/logfile-open v1.1.1
github.com/alessio/shellescape v1.4.1
github.com/antonmedv/expr v1.12.5
github.com/bmatcuk/doublestar/v4 v4.6.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ gitea.com/6543/xorm v1.3.3-0.20230807141308-fc77a3b490a8/go.mod h1:qFJGFoVYbbIdn
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a h1:lSA0F4e9A2NcQSqGqTOXqu2aRi/XEQxDCBwM8yJtE6s=
gitea.com/xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:EXuID2Zs0pAQhH8yz+DNjUbjppKQzKFAn28TMYPB6IU=
gitee.com/travelliu/dm v1.8.11192/go.mod h1:DHTzyhCrM843x9VdKVbZ+GKXGRbKM2sJ4LxihRxShkE=
github.com/6543/logfile-open v1.1.1 h1:OKBz2GwxGaJRAOZehsSAl9antvHDG3yq83cpQcQ26aw=
github.com/6543/logfile-open v1.1.1/go.mod h1:ZoEy7pW2mexmQxiZIqPCeh8vUxVuiHYXmSZNbvEb51g=
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw=
github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0=
github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8=
Expand Down