aggiunta l'opzione -R <retention> default = 15552000 (6 mesi)

This commit is contained in:
Michele 2018-10-24 09:33:08 +02:00
parent e1f9da40e4
commit 6572d95834
4 changed files with 7 additions and 12 deletions

View file

@ -15,10 +15,6 @@ import (
"gopkg.in/mgo.v2" "gopkg.in/mgo.v2"
) )
const (
RETENTION = 15552000
)
type consumed struct { type consumed struct {
user string user string
error bool error bool
@ -85,7 +81,7 @@ func consumer() {
} }
// se la data e' piu vecchia di RETENTION (15552000 sec) la scarta // se la data e' piu vecchia di RETENTION (15552000 sec) la scarta
if time.Since(time.Unix(date, 0)).Seconds()-RETENTION >= 0 { if time.Since(time.Unix(date, 0)).Seconds()-opts.Retention >= 0 {
log.Printf("Date Warning: %+v - %s - %s\n", time.Unix(date, 0), prod.user, login) log.Printf("Date Warning: %+v - %s - %s\n", time.Unix(date, 0), prod.user, login)
if opts.Debug { if opts.Debug {
fmt.Printf("Date Warning: %+v - %s - %s\n", time.Unix(date, 0), prod.user, login) fmt.Printf("Date Warning: %+v - %s - %s\n", time.Unix(date, 0), prod.user, login)

View file

@ -4,11 +4,10 @@ docker run \
--rm \ --rm \
-v /opt/WORK/PROJECTS/New_Mail/lastlogin_mongodb/docker-compose/llmongo:/data \ -v /opt/WORK/PROJECTS/New_Mail/lastlogin_mongodb/docker-compose/llmongo:/data \
--name llmongo \ --name llmongo \
mikif70/llmongo:4.4.0 \ mikif70/llmongo:4.4.1b \
-l /data/llmongo.log \ -l /data/llmongo.log \
-r 192.168.0.1:6379 \ -r 192.168.0.1:6379 \
-m 192.168.0.1:27017 \ -m 192.168.0.1:27017 \
-d lastlogin \ -d lastlogin \
-T 80s \ -T 80s \
-D \
$@ $@

View file

@ -14,7 +14,7 @@ import (
) )
const ( const (
_Version = "v4.4.1b" _Version = "v4.4.1"
_Producer = 0 _Producer = 0
_Consumer = 1 _Consumer = 1
_Remover = 2 _Remover = 2

View file

@ -25,8 +25,8 @@ type Options struct {
MaxError int MaxError int
Influxdb string Influxdb string
Month string Month string
// Pidfile string Queue int
Queue int Retention float64
} }
var ( var (
@ -46,6 +46,7 @@ func usage() {
-T <running timeout> -T <running timeout>
-i <influxdb [localname@ip:port]> -i <influxdb [localname@ip:port]>
-q <parallel consumer> -q <parallel consumer>
-R <retention>
-v <version> -v <version>
-D <debug> -D <debug>
-DD <Test>`) -DD <Test>`)
@ -61,7 +62,6 @@ func init() {
} }
opts.LogFile = path.Join(opts.CurrentPath, opts.LogFile) opts.LogFile = path.Join(opts.CurrentPath, opts.LogFile)
// opts.Pidfile = path.Join(opts.CurrentPath, "run", path.Base(os.Args[0])+".pid")
opts.Exe = path.Base(os.Args[0]) opts.Exe = path.Base(os.Args[0])
flag.StringVar(&opts.Influxdb, "i", "", "influxdb server") flag.StringVar(&opts.Influxdb, "i", "", "influxdb server")
@ -76,5 +76,5 @@ func init() {
flag.BoolVar(&opts.Test, "DD", false, "Test") flag.BoolVar(&opts.Test, "DD", false, "Test")
flag.IntVar(&opts.MaxError, "E", 100, "Max Mongodb Error") flag.IntVar(&opts.MaxError, "E", 100, "Max Mongodb Error")
flag.IntVar(&opts.Queue, "q", 2, "parallel consumer") flag.IntVar(&opts.Queue, "q", 2, "parallel consumer")
// flag.StringVar(&opts.Pidfile, "p", opts.Pidfile, "pid file") flag.Float64Var(&opts.Retention, "R", 15552000, "retention")
} }