Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions hossted/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,24 +385,37 @@ func PrettyPrint(i interface{}) string {
func stopTraefik(appDir string) error {
fmt.Println("Stopping traefik...")

command := []string{"sudo docker compose down"}
err, _, stderr := Shell(appDir, command)
// Construct the docker compose down command
cmd := exec.Command("sudo", "docker", "compose", "down")
cmd.Dir = appDir // Set the working directory for the command

// Run the command and capture stdout and stderr
output, err := cmd.CombinedOutput()
if err != nil {
return err
return fmt.Errorf("error stopping traefik: %v\nOutput: %s", err, string(output))
}
fmt.Println(trimOutput(stderr))
fmt.Println("traefik stopeed")

// Print the trimmed output for debugging
fmt.Println(string(output))
fmt.Println("Traefik stopped")
return nil
}

func dockerUp(appDir string) error {
fmt.Println("Restarting service...")

command := []string{"sudo docker compose up -d"}
err, _, stderr := Shell(appDir, command)
// Construct the docker compose command
cmd := exec.Command("sudo", "docker", "compose", "up", "-d")
cmd.Dir = appDir // Set the working directory for the command

// Run the command and capture stdout and stderr
output, err := cmd.CombinedOutput()
if err != nil {
return err
return fmt.Errorf("error running docker compose: %v\nOutput: %s", err, string(output))
}
fmt.Println(trimOutput(stderr))

// Print the trimmed output for debugging
fmt.Println(string(output))
return nil
}

Expand Down Expand Up @@ -575,7 +588,7 @@ func sendActivityLog(env, uuid, fullCommand, options, typeActivity string) (acti

user, err := user.Current()
if err != nil {
log.Fatalf(err.Error())
log.Fatalf("%s", err.Error())
}

userName := user.Username
Expand Down Expand Up @@ -605,10 +618,10 @@ func sendActivityLog(env, uuid, fullCommand, options, typeActivity string) (acti

err = json.Unmarshal([]byte(resp), &response)
if err != nil {
return response, fmt.Errorf("Failed to parse JSON. %w", err)
return response, fmt.Errorf("failed to parse JSON. %w", err)
}

//fmt.Printf("%v \n", response.Message)
fmt.Printf("calling to activity log api %s\n", response.Message)
return response, nil

}
Expand Down
Loading