From 75da8c7a712324d11f5f643c9f1ab112cc4a8211 Mon Sep 17 00:00:00 2001 From: dave Date: Thu, 9 Nov 2017 19:34:12 -0800 Subject: [PATCH] Misc fixes --- build.sh | 2 +- src/archive.go | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index 320c110..b209a21 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -ex dpkg-buildpackage -us -uc -b diff --git a/src/archive.go b/src/archive.go index 50214a3..d63526d 100644 --- a/src/archive.go +++ b/src/archive.go @@ -22,6 +22,7 @@ var ( cmd_import_dir = cmd_import.Flag("dir", "dir containing raw znc log files").Short('d').Required().String() cmd_import_output = cmd_import.Flag("output", "dir to place created archives").Short('o').Required().String() cmd_import_all = cmd_import.Flag("all", "Import all log files, not only channels").Bool() + cmd_import_parallel = cmd_import.Flag("parallel", "How many importers can run in parallel").Short('p').Default("4").Int() cmd_inspect = kingpin.Command("inspect", "Enumerate the contents of archives") cmd_inspect_fpath = cmd_inspect.Flag("file", "log archive file to inspect").Short('f').Required().String() @@ -110,6 +111,7 @@ func archive_log(logs []LogInfo, archive_path string) { archive := CombinedLogfile{ fpath: archive_path, } + archive.Parse() // For each log for _, log := range logs { // Load the log into a LogPortion @@ -139,7 +141,7 @@ func archive_log(logs []LogInfo, archive_path string) { // Entrypoint for the `import` command. Given an srcdir, scan it for log files. The log files will be sorted by channel // and combined into an archive file per channel, placed in `outdir`. The `impall` flag determines whether only channel // logs will be imported. If `true`, non-channel logs, such as PMs or server messages, will be archived too. -func cmd_import_do(srcdir string, outdir string, impall bool) { +func cmd_import_do(srcdir string, outdir string, impall bool, parallel int) { raw_logs := discover_logs(srcdir) // Sort logs by channel @@ -153,7 +155,7 @@ func cmd_import_do(srcdir string, outdir string, impall bool) { fmt.Printf("Discovered %v raw logs\n\n", len(raw_logs)) // For each channel - wg := sizedwaitgroup.New(4) // TODO num cores + wg := sizedwaitgroup.New(parallel) for channel, logs := range bychannel { fmt.Printf("Reading %v portions for %s\n", len(logs), channel) @@ -190,8 +192,8 @@ func cmd_inspect_do(fpath string) { []string{"network", log.Network}, []string{"portions", strconv.Itoa(len(log.portions))}, []string{"lines", strconv.Itoa(log.TotalLines())}, - []string{"start", lmin.Format("2006-01-02")}, - []string{"end", lmax.Format("2006-01-02")}, + []string{"start", lmin.Format(ARCHTIMEFMT2)}, + []string{"end", lmax.Format(ARCHTIMEFMT2)}, } layout := &tabulate.Layout{Headers:[]string{"property", "value"}, Format:tabulate.SimpleFormat} asText, _ := tabulate.Tabulate(table, layout) @@ -236,7 +238,7 @@ func cmd_split_do(srcpath string, destdir string) { func main() { switch kingpin.Parse() { case "import": - cmd_import_do(*cmd_import_dir, *cmd_import_output, *cmd_import_all) + cmd_import_do(*cmd_import_dir, *cmd_import_output, *cmd_import_all, *cmd_import_parallel) case "inspect": cmd_inspect_do(*cmd_inspect_fpath) case "slice":