From 594dc2e0d4ce3124732b3bcf71a92c002b912466 Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Sat, 2 Jul 2022 23:35:26 +0000 Subject: [PATCH] modify arthur status message --- merlin/README.md | 2 ++ merlin/arthur/arthur.go | 13 ++++++++++--- merlin/cmd/arthur/arthur.go | 3 ++- merlin/merlin-config.ini | 1 - 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/merlin/README.md b/merlin/README.md index 9ec4ef4..741fc98 100644 --- a/merlin/README.md +++ b/merlin/README.md @@ -14,6 +14,8 @@ Then configure `merlin-config.ini` and run using `./merlin` ### Nice Features To Add - detect if an rsync process is stuck (watch the stdout/stderr of the rsync processes) - get the config or the rsync commond that a repo will sync with using a cli tool +- improve conversion from exit status enum to string +- sort `arthur status` by last time synced ### Completed - [x] add bwlimit option for each rsync process diff --git a/merlin/arthur/arthur.go b/merlin/arthur/arthur.go index df59ad6..95272e2 100644 --- a/merlin/arthur/arthur.go +++ b/merlin/arthur/arthur.go @@ -53,11 +53,11 @@ func SendStatus(conn net.Conn) { } status := tabwriter.NewWriter(conn, 5, 5, 5, ' ', 0) - fmt.Fprintf(status, "Repository\tLast Synced\tNext Expected Sync\tRunning\n") + fmt.Fprintf(status, "Repository\tLast Synced\tNext Expected Sync\tLast Exit\tRunning\n") // get the names of all of the repos in the config var keys []string - for name, _ := range config.RepoMap { + for name := range config.RepoMap { keys = append(keys, name) } sort.Strings(keys) @@ -68,11 +68,18 @@ func SendStatus(conn net.Conn) { repo := config.RepoMap[name] lastSync := repo.State.LastAttemptStartTime nextSync := lastSync + int64(repo.Frequency) + lastExit := "failed" + if repo.State.LastAttemptExit == config.SUCCESS { + lastExit = "completed" + } else if repo.State.LastAttemptExit == config.TERMINATED { + lastExit = "terminated" + } - fmt.Fprintf(status, "%s\t%s\t%s\t%t\n", + fmt.Fprintf(status, "%s\t%s\t%s\t%s\t%t\n", name, time.Unix(lastSync, 0).In(location).Format(time.RFC1123), time.Unix(nextSync, 0).In(location).Format(time.RFC1123), + lastExit, repo.State.IsRunning, ) } diff --git a/merlin/cmd/arthur/arthur.go b/merlin/cmd/arthur/arthur.go index 4638e13..d3a0de5 100644 --- a/merlin/cmd/arthur/arthur.go +++ b/merlin/cmd/arthur/arthur.go @@ -9,7 +9,8 @@ import ( "os" ) -var DEFAULT_SOCKET_PATH = "/home/mirror/merlin/merlin.sock" +// var DEFAULT_SOCKET_PATH = "/home/mirror/merlin/merlin.sock" +var DEFAULT_SOCKET_PATH = "/mirror/merlin/run/merlin-go.sock" var HELP_MESSAGE = `USAGE: arthur [-h|--help] [--sock ] COMMAND diff --git a/merlin/merlin-config.ini b/merlin/merlin-config.ini index d1b1d62..bd290d5 100644 --- a/merlin/merlin-config.ini +++ b/merlin/merlin-config.ini @@ -15,7 +15,6 @@ sock_path = /mirror/merlin/run/merlin-go.sock [puppylinux] verbose = true -dry_run = true sync_type = csc-sync-standard frequency = twice-daily local_dir = puppylinux