modify arthur status message

This commit is contained in:
Andrew Wang 2022-07-02 23:35:26 +00:00
parent 2492d533f0
commit 594dc2e0d4
4 changed files with 14 additions and 5 deletions

View File

@ -14,6 +14,8 @@ Then configure `merlin-config.ini` and run using `./merlin`
### Nice Features To Add ### Nice Features To Add
- detect if an rsync process is stuck (watch the stdout/stderr of the rsync processes) - 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 - 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 ### Completed
- [x] add bwlimit option for each rsync process - [x] add bwlimit option for each rsync process

View File

@ -53,11 +53,11 @@ func SendStatus(conn net.Conn) {
} }
status := tabwriter.NewWriter(conn, 5, 5, 5, ' ', 0) 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 // get the names of all of the repos in the config
var keys []string var keys []string
for name, _ := range config.RepoMap { for name := range config.RepoMap {
keys = append(keys, name) keys = append(keys, name)
} }
sort.Strings(keys) sort.Strings(keys)
@ -68,11 +68,18 @@ func SendStatus(conn net.Conn) {
repo := config.RepoMap[name] repo := config.RepoMap[name]
lastSync := repo.State.LastAttemptStartTime lastSync := repo.State.LastAttemptStartTime
nextSync := lastSync + int64(repo.Frequency) 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, name,
time.Unix(lastSync, 0).In(location).Format(time.RFC1123), time.Unix(lastSync, 0).In(location).Format(time.RFC1123),
time.Unix(nextSync, 0).In(location).Format(time.RFC1123), time.Unix(nextSync, 0).In(location).Format(time.RFC1123),
lastExit,
repo.State.IsRunning, repo.State.IsRunning,
) )
} }

View File

@ -9,7 +9,8 @@ import (
"os" "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: var HELP_MESSAGE = `USAGE:
arthur [-h|--help] [--sock <socket_path>] COMMAND arthur [-h|--help] [--sock <socket_path>] COMMAND

View File

@ -15,7 +15,6 @@ sock_path = /mirror/merlin/run/merlin-go.sock
[puppylinux] [puppylinux]
verbose = true verbose = true
dry_run = true
sync_type = csc-sync-standard sync_type = csc-sync-standard
frequency = twice-daily frequency = twice-daily
local_dir = puppylinux local_dir = puppylinux