mostly formatting
This commit is contained in:
parent
bef25c73f5
commit
a13b29d957
@ -109,9 +109,21 @@ func main() {
|
||||
case "add":
|
||||
fmt.Println("Add instance")
|
||||
case "status":
|
||||
fmt.Println("Status:" + responseback.Message)
|
||||
for x, runninginstance := range responseback.RunningInstances {
|
||||
fmt.Println("ID:", x, runninginstance.Endpoint, runninginstance.Status, runninginstance.LastRun)
|
||||
for _, runninginstance := range responseback.RunningInstances {
|
||||
if runninginstance.Status == 0 {
|
||||
fmt.Fprintf(os.Stdout, "New\t")
|
||||
} else if runninginstance.Status == 200 {
|
||||
fmt.Fprintf(os.Stdout, "Running\t")
|
||||
} else if runninginstance.Status == 602 {
|
||||
fmt.Fprintf(os.Stdout, "BadInstance")
|
||||
} else {
|
||||
fmt.Fprintf(os.Stdout, "%d\t", runninginstance.Status)
|
||||
}
|
||||
fmt.Fprintf(os.Stdout, "\t%s\t", runninginstance.LastRun)
|
||||
if runninginstance.LastRun == "Queued" {
|
||||
fmt.Fprintf(os.Stdout, "\t\t")
|
||||
}
|
||||
fmt.Fprintf(os.Stdout, "%s\n", runninginstance.Endpoint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,14 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
INSTANCE_ERROR = -1
|
||||
NEW_INSTANCE = 0
|
||||
RUNNING = 200
|
||||
TOOMANYREQUESTS = 429
|
||||
CLIENT_ISSUE = 600
|
||||
ONION_PROTOCOL = 601
|
||||
UNMARSHAL_ERROR = 602
|
||||
BAD_RESPONSE = 602
|
||||
NO_CONNECTION = 603
|
||||
BAD_NODEINFO = 604
|
||||
)
|
||||
|
||||
// Parsing Unmarshal JSON type
|
||||
@ -121,7 +121,7 @@ func handleClient(commandClient net.Conn, runninginstances *[]RunningInstance, i
|
||||
case "status":
|
||||
responseback.Message = "Ok"
|
||||
case "add":
|
||||
fmt.Println("Add instance: " + commandmap.Endpoint)
|
||||
log.Print("Manually added instance: " + commandmap.Endpoint)
|
||||
var q InstanceReport
|
||||
q.endpoint = commandmap.Endpoint
|
||||
q.status = NEW_INSTANCE
|
||||
@ -204,7 +204,7 @@ func StartInstancePoll(instancereport InstanceReport, reportPostChan chan Report
|
||||
err = json.Unmarshal(body, &newposts)
|
||||
if err != nil {
|
||||
// instanceReportChan <- InstanceReport{instancereport.endpoint, resp.StatusCode, "", 0}
|
||||
instanceReportChan <- InstanceReport{instancereport.endpoint, 999, "", 0}
|
||||
instanceReportChan <- InstanceReport{instancereport.endpoint, BAD_RESPONSE, "", 0}
|
||||
return
|
||||
}
|
||||
|
||||
@ -340,13 +340,13 @@ func NewInstance(endpoint string, runninginstances *[]RunningInstance, instanceR
|
||||
go func() {
|
||||
var q InstanceReport
|
||||
q.endpoint = endpoint
|
||||
q.status = INSTANCE_ERROR
|
||||
q.status = BAD_NODEINFO
|
||||
instanceReportChan <- q
|
||||
return
|
||||
}()
|
||||
}
|
||||
|
||||
newinstance := RunningInstance{endpoint, "", "", NEW_INSTANCE, "QUEUED"}
|
||||
newinstance := RunningInstance{endpoint, "", "", NEW_INSTANCE, "Queued"}
|
||||
*runninginstances = append(*runninginstances, newinstance)
|
||||
|
||||
if nodeinfo.Software.Name == "pleroma" || nodeinfo.Software.Name == "mastodon" {
|
||||
@ -385,7 +385,7 @@ func writePost(pool *pgxpool.Pool, reportpost ReportPost) {
|
||||
fmt.Println("Account URL: ", reportpost.Account.Url)
|
||||
fmt.Println(reportpost)
|
||||
fmt.Println("--------------------------")
|
||||
os.Exit(1) // For now I want this to die and learn why it failed
|
||||
// os.Exit(1) // For now I want this to die and learn why it failed
|
||||
return
|
||||
}
|
||||
|
||||
@ -402,7 +402,7 @@ func writePost(pool *pgxpool.Pool, reportpost ReportPost) {
|
||||
fmt.Println("account_id", accountid)
|
||||
fmt.Println("posthash: ", reportpost.posthash)
|
||||
fmt.Println("--------------------------")
|
||||
os.Exit(1) // For now I want this to die and learn why it failed
|
||||
// os.Exit(1) // For now I want this to die and learn why it failed
|
||||
return
|
||||
}
|
||||
}
|
||||
@ -411,6 +411,7 @@ func SuspendInstance(suspendinstance InstanceReport, runninginstances *[]Running
|
||||
for i, runninginstance := range *runninginstances {
|
||||
if runninginstance.Endpoint == suspendinstance.endpoint {
|
||||
(*runninginstances)[i].Status = suspendinstance.status
|
||||
(*runninginstances)[i].LastRun = time.Now().Format("2006.01.02-15:04:05")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user