@@ -28,12 +28,21 @@ import (
28
28
"github.com/thediveo/enumflag"
29
29
)
30
30
31
+ const (
32
+ defaultQueueTimeout = 10 * time .Second
33
+ defaultMaxJobSize = 50 * units .MiB
34
+ defaultCompileTimeout = time .Minute
35
+ defaultRetentionPoolSize = 100 * units .MiB
36
+
37
+ exitFlagErr = 2
38
+ )
39
+
31
40
var opts = service.Options {
32
41
Addr : ":2201" ,
33
42
QueueLength : runtime .GOMAXPROCS (0 ),
34
- QueueTimeout : 10 * time . Second ,
35
- MaxJobSize : 50 * units . MiB ,
36
- CompileTimeout : time . Minute ,
43
+ QueueTimeout : defaultQueueTimeout ,
44
+ MaxJobSize : defaultMaxJobSize ,
45
+ CompileTimeout : defaultCompileTimeout ,
37
46
Mode : "local" ,
38
47
Executor : exec .LocalExec ,
39
48
KeepJobs : service .KeepJobsNever ,
60
69
1 : {"purge" , "purge-on-start" },
61
70
2 : {"access" },
62
71
}
63
- retPolItems = 1000 // number of items in refstore
64
- retPolSize = units .BytesSize (float64 (100 * units . MiB )) // max total file size
72
+ retPolItems = 1000 // number of items in refstore
73
+ retPolSize = units .BytesSize (float64 (defaultRetentionPoolSize )) // max total file size
65
74
)
66
75
67
76
func retentionPolicy () (refstore.RetentionPolicy , error ) {
@@ -70,7 +79,7 @@ func retentionPolicy() (refstore.RetentionPolicy, error) {
70
79
return & refstore.KeepForever {}, nil
71
80
case 1 :
72
81
return & refstore.PurgeOnStart {}, nil
73
- case 2 :
82
+ case 2 : //nolint:mnd
74
83
sz , err := units .FromHumanSize (retPolSize )
75
84
if err != nil {
76
85
return nil , err
@@ -129,13 +138,13 @@ func parseFlags() []string {
129
138
os .Exit (0 )
130
139
case err != nil :
131
140
fmt .Fprintf (os .Stderr , "Error parsing flags:\n \t %v\n " , err )
132
- os .Exit (2 )
141
+ os .Exit (exitFlagErr )
133
142
}
134
143
135
144
return fs .Args ()
136
145
}
137
146
138
- func main () {
147
+ func main () { //nolint:funlen
139
148
texd .PrintBanner (os .Stdout )
140
149
images := parseFlags () //nolint:ifshort // func has sideeffects
141
150
log , err := setupLogger ()
@@ -158,12 +167,12 @@ func main() {
158
167
xlog .String ("flag" , "--tex-engine" ),
159
168
xlog .Error (err ))
160
169
}
161
- if max , err := units .FromHumanSize (maxJobSize ); err != nil {
170
+ if maxsz , err := units .FromHumanSize (maxJobSize ); err != nil {
162
171
log .Fatal ("error parsing maximum job size" ,
163
172
xlog .String ("flag" , "--max-job-size" ),
164
173
xlog .Error (err ))
165
174
} else {
166
- opts .MaxJobSize = max
175
+ opts .MaxJobSize = maxsz
167
176
}
168
177
if storageDSN != "" {
169
178
rp , err := retentionPolicy ()
@@ -212,7 +221,7 @@ const exitTimeout = 10 * time.Second
212
221
type stopFun func (context.Context ) error
213
222
214
223
func onExit (log xlog.Logger , stopper ... stopFun ) {
215
- exitCh := make (chan os.Signal , 2 )
224
+ exitCh := make (chan os.Signal , 2 ) //nolint:mnd // idiomatic
216
225
signal .Notify (exitCh , syscall .SIGINT , syscall .SIGTERM )
217
226
sig := <- exitCh
218
227
0 commit comments