Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions api/restart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions api/restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down Expand Up @@ -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
},
}
Expand All @@ -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
},
}
Expand Down
Loading