Replaced fmt with log calls
parent
d7aabfdbe8
commit
461a9e6558
|
@ -4,6 +4,7 @@ import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
@ -111,26 +112,27 @@ func ExecuteTask(task Task) Task {
|
||||||
}
|
}
|
||||||
|
|
||||||
if Version == "dev" {
|
if Version == "dev" {
|
||||||
fmt.Println("Dev environemnt. Not executing tasks.")
|
log.Printf("Dev environemnt. Not executing tasks.")
|
||||||
} else {
|
} else {
|
||||||
switch task.Task {
|
switch task.Task {
|
||||||
case "setup_bootnode":
|
case "setup_bootnode":
|
||||||
|
|
||||||
fmt.Println("Setting up bootnode connection...")
|
log.Println("Setting up bootnode connection...")
|
||||||
var args taskSetupBootnodeArgs
|
var args taskSetupBootnodeArgs
|
||||||
err := json.Unmarshal([]byte(task.Args), &args)
|
err := json.Unmarshal([]byte(task.Args), &args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Error reading arguments of setup_bootnode task: %s", err)
|
log.Printf("Error reading arguments of setup_bootnode task: %s", err)
|
||||||
} else {
|
} else {
|
||||||
task.Result = sql.NullString{String: taskSetupBootnode(args), Valid: true}
|
taskResult = taskSetupBootnode(args)
|
||||||
|
task.Result = sql.NullString{String: taskResult, Valid: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
case "start_edgeapp":
|
case "start_edgeapp":
|
||||||
fmt.Println("Starting EdgeApp...")
|
log.Printf("Starting EdgeApp...")
|
||||||
task.Result = sql.NullString{String: taskStartEdgeApp(), Valid: true}
|
task.Result = sql.NullString{String: taskStartEdgeApp(), Valid: true}
|
||||||
// ...
|
// ...
|
||||||
case "stop_edgeapp":
|
case "stop_edgeapp":
|
||||||
fmt.Println("Stopping EdgeApp...")
|
log.Printf("Stopping EdgeApp...")
|
||||||
task.Result = sql.NullString{String: taskStopEdgeApp(), Valid: true}
|
task.Result = sql.NullString{String: taskStopEdgeApp(), Valid: true}
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
@ -156,26 +158,28 @@ func ExecuteTask(task Task) Task {
|
||||||
|
|
||||||
func taskSetupBootnode(args taskSetupBootnodeArgs) string {
|
func taskSetupBootnode(args taskSetupBootnodeArgs) string {
|
||||||
|
|
||||||
|
fmt.Println("Executing taskSetupBootnode")
|
||||||
|
|
||||||
out, err := exec.Command("tinc-boot", "gen", "--name "+args.NodeName, "--token "+args.BootnodeToken, args.BootnodeAddress+":8655", "--prefix "+args.AssignedAddress).Output()
|
out, err := exec.Command("tinc-boot", "gen", "--name "+args.NodeName, "--token "+args.BootnodeToken, args.BootnodeAddress+":8655", "--prefix "+args.AssignedAddress).Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%s", err)
|
log.Printf("Error: %s", err)
|
||||||
}
|
}
|
||||||
output := string(out[:])
|
output := string(out[:])
|
||||||
fmt.Println(output)
|
fmt.Println(output)
|
||||||
|
|
||||||
out, err = exec.Command("systemctl", "start", "tinc@dnet").Output()
|
out, err = exec.Command("systemctl", "start", "tinc@dnet").Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%s", err)
|
log.Printf("Error: %s", err)
|
||||||
}
|
}
|
||||||
output = string(out[:])
|
output = string(out[:])
|
||||||
fmt.Println(output)
|
log.Printf(output)
|
||||||
|
|
||||||
out, err = exec.Command("systemctl", "enable", "tinc@dnet").Output()
|
out, err = exec.Command("systemctl", "enable", "tinc@dnet").Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%s", err)
|
log.Printf("Error: %s", err)
|
||||||
}
|
}
|
||||||
output = string(out[:])
|
output = string(out[:])
|
||||||
fmt.Println(output)
|
log.Printf(output)
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue