From 4ca94515badefad3508804ba533a23581cfc2353 Mon Sep 17 00:00:00 2001 From: jmbenlloch Date: Fri, 13 Nov 2026 14:41:39 +0100 Subject: [PATCH] fix(api): restart Duck Compose services as duck --- api/restart.go | 6 +++--- api/restart_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/api/restart.go b/api/restart.go index 249f1de..7e9e8e5 100644 --- a/api/restart.go +++ b/api/restart.go @@ -67,7 +67,7 @@ func restartServices(configFilename string) error { func restartService(name string, role ServerRole, host string) { message := fmt.Sprintf("Restarting services on %s", name) logger.Slog.Info(message) - sshClient, err := sshClientCreator("dateuser", host) + sshClient, err := sshClientCreator("duck", host) if err != nil { message := fmt.Errorf("could not restart services on %s: %w", name, err) logger.Slog.Error(message.Error()) @@ -90,9 +90,9 @@ func restartDuckSSH(sshClient SSHClient, name string, role ServerRole) error { var cmd string switch role { case GDCRole: - cmd = "/home/dateuser/duck/restart_gdc.sh" + cmd = "docker compose --project-directory /home/duck/duck-daq -p duck-daq restart gdc" case LDCRole: - cmd = "/home/dateuser/duck/restart_ldc.sh" + cmd = "docker compose --project-directory /home/duck/duck-daq -p duck-daq restart ldc" } out, err := sshClient.Run(cmd) if err != nil { diff --git a/api/restart_test.go b/api/restart_test.go index d8f188d..3540e09 100644 --- a/api/restart_test.go +++ b/api/restart_test.go @@ -47,7 +47,7 @@ func TestRestartService_Success(t *testing.T) { defer func() { sshClientCreator = oldCreator }() sshClientCreator = func(user, host string) (SSHClient, error) { - assert.Equal(t, "dateuser", user) + assert.Equal(t, "duck", user) assert.Equal(t, "test.example.com", host) return mockClient, nil } @@ -59,7 +59,7 @@ func TestRestartService_Success(t *testing.T) { // Assert assert.True(t, mockClient.RunCalled) - assert.Equal(t, "/home/dateuser/duck/restart_gdc.sh", mockClient.LastCmd) + assert.Equal(t, "docker compose --project-directory /home/duck/duck-daq -p duck-daq restart gdc", mockClient.LastCmd) } // TestRestartService_SSHConnectionError tests SSH connection failure @@ -109,7 +109,7 @@ func TestRestartService_CommandError(t *testing.T) { func TestRestartDuckSSH_GDCRole(t *testing.T) { mockClient := &MockSSHClient{ RunFunc: func(cmd string) ([]byte, error) { - assert.Equal(t, "/home/dateuser/duck/restart_gdc.sh", cmd) + assert.Equal(t, "docker compose --project-directory /home/duck/duck-daq -p duck-daq restart gdc", cmd) return []byte("GDC restarted"), nil }, } @@ -128,7 +128,7 @@ func TestRestartDuckSSH_GDCRole(t *testing.T) { func TestRestartDuckSSH_LDCRole(t *testing.T) { mockClient := &MockSSHClient{ RunFunc: func(cmd string) ([]byte, error) { - assert.Equal(t, "/home/dateuser/duck/restart_ldc.sh", cmd) + assert.Equal(t, "docker compose --project-directory /home/duck/duck-daq -p duck-daq restart ldc", cmd) return []byte("LDC restarted"), nil }, }