File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import (
24
24
"net/http"
25
25
"os"
26
26
"os/signal"
27
+ "syscall"
27
28
"time"
28
29
29
30
"github.com/cloudbase/garm/apiserver/controllers"
@@ -37,6 +38,7 @@ import (
37
38
"github.com/cloudbase/garm/util"
38
39
"github.com/cloudbase/garm/util/appdefaults"
39
40
"github.com/cloudbase/garm/websocket"
41
+ lumberjack "gopkg.in/natefinch/lumberjack.v2"
40
42
41
43
"github.com/gorilla/handlers"
42
44
"github.com/gorilla/mux"
@@ -82,6 +84,26 @@ func main() {
82
84
log .Fatalf ("fetching log writer: %+v" , err )
83
85
}
84
86
87
+ // rotate log file on SIGHUP
88
+ ch := make (chan os.Signal , 1 )
89
+ signal .Notify (ch , syscall .SIGHUP )
90
+ go func () {
91
+ for {
92
+ select {
93
+ case <- ctx .Done ():
94
+ // Daemon is exiting.
95
+ return
96
+ case <- ch :
97
+ // we got a SIGHUP. Rotate log file.
98
+ if logger , ok := logWriter .(* lumberjack.Logger ); ok {
99
+ if err := logger .Rotate (); err != nil {
100
+ log .Printf ("failed to rotate log file: %v" , err )
101
+ }
102
+ }
103
+ }
104
+ }
105
+ }()
106
+
85
107
var writers []io.Writer = []io.Writer {
86
108
logWriter ,
87
109
}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ After=multi-user.target
5
5
[Service]
6
6
Type =simple
7
7
ExecStart =/usr/local/bin/garm -config /etc/garm/config.toml
8
+ ExecReload =/bin/kill -HUP $MAINPID
8
9
Restart =always
9
10
RestartSec =5s
10
11
User =garm
Original file line number Diff line number Diff line change
1
+ # Logging
2
+
3
+ By default, GARM is logging only on standard output.
4
+
5
+ If you would like GARM to use a logging file instead, you can use the ` log_file ` configuration option:
6
+
7
+ ``` toml
8
+ [default ]
9
+ # Use this if you'd like to log to a file instead of standard output.
10
+ log_file = " /tmp/runner-manager.log"
11
+ ```
12
+
13
+ ## Rotating log files
14
+
15
+ If GARM uses a log file, by default it will rotate it when it reaches 500MB or 28 days, whichever comes first.
16
+
17
+ However, if you want to manually rotate the log file, you can send a ` SIGHUP ` signal to the GARM process.
You can’t perform that action at this time.
0 commit comments