1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 05:40:11 +01:00

Add option no_lock to use no lock file if none was configured

This commit is contained in:
JanHoefelmeyer 2023-03-17 13:00:51 +01:00
parent 8f87273837
commit bb053bd427
3 changed files with 13 additions and 1 deletions

View file

@ -34,6 +34,10 @@ const (
defaultUpdateInterval = "on best effort" defaultUpdateInterval = "on best effort"
) )
var (
defaultLockFile = "/var/csaf_aggregator/run.lock"
)
type provider struct { type provider struct {
Name string `toml:"name"` Name string `toml:"name"`
Domain string `toml:"domain"` Domain string `toml:"domain"`
@ -71,6 +75,7 @@ type config struct {
// LockFile tries to lock to a given file. // LockFile tries to lock to a given file.
LockFile *string `toml:"lock_file"` LockFile *string `toml:"lock_file"`
NoLock bool `toml:"no_lock"`
// Interim performs an interim scan. // Interim performs an interim scan.
Interim bool `toml:"interim"` Interim bool `toml:"interim"`
@ -262,6 +267,10 @@ func (c *config) setDefaults() {
c.Domain = defaultDomain c.Domain = defaultDomain
} }
if !c.NoLock && c.LockFile == nil {
c.LockFile = &defaultLockFile
}
if c.Workers <= 0 { if c.Workers <= 0 {
if n := runtime.NumCPU(); n > defaultWorkers { if n := runtime.NumCPU(); n > defaultWorkers {
c.Workers = defaultWorkers c.Workers = defaultWorkers

View file

@ -91,7 +91,8 @@ openpgp_private_key // OpenPGP private key (must have no passphrase set, if
// you want to be able to run unattended, e.g. via cron.) // you want to be able to run unattended, e.g. via cron.)
openpgp_public_key // OpenPGP public key openpgp_public_key // OpenPGP public key
passphrase // passphrase of the OpenPGP key passphrase // passphrase of the OpenPGP key
lock_file // path to lockfile, to stop other instances if one is not done (default no locking) lock_file // path to lockfile, to stop other instances if one is not done (default:run.lock)
no_lock // explicitely disable usage of lock files. (default: false)
interim_years // limiting the years for which interim documents are searched (default 0) interim_years // limiting the years for which interim documents are searched (default 0)
verbose // print more diagnostic output, e.g. https requests (default false) verbose // print more diagnostic output, e.g. https requests (default false)
allow_single_provider // debugging option (default false) allow_single_provider // debugging option (default false)
@ -158,6 +159,7 @@ categories document. For a more detailed explanation and examples,
workers = 2 workers = 2
folder = "/var/csaf_aggregator" folder = "/var/csaf_aggregator"
lock_file = "/var/csaf_aggregator/run.lock" lock_file = "/var/csaf_aggregator/run.lock"
#no_lock = false
web = "/var/csaf_aggregator/html" web = "/var/csaf_aggregator/html"
domain = "https://localhost:9443" domain = "https://localhost:9443"
rate = 10.0 rate = 10.0

View file

@ -1,6 +1,7 @@
workers = 2 workers = 2
folder = "/var/csaf_aggregator" folder = "/var/csaf_aggregator"
lock_file = "/var/csaf_aggregator/run.lock" lock_file = "/var/csaf_aggregator/run.lock"
#no_lock = false
web = "/var/csaf_aggregator/html" web = "/var/csaf_aggregator/html"
domain = "https://localhost:9443" domain = "https://localhost:9443"
rate = 10.0 rate = 10.0