Skip to content

Commit 7b8e541

Browse files
committed
Make service display name unique on Windows.
1 parent b6bd76a commit 7b8e541

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

internal/pkg/agent/application/paths/common_development_mode.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ import "path/filepath"
99

1010
// DevelopmentInstallDirName is the name of the directory agent will be installed to within the base path.
1111
// For example it is $BasePath/$DevelopmentInstallDirName, on MacOS it is /Library/Elastic/$DevelopmentInstallDirName.
12-
const DevelopmentInstallDirName string = "DevelopmentAgent"
12+
const (
13+
DevelopmentInstallDirName = "DevelopmentAgent"
14+
15+
// Service display names. Must be different from the ServiceName() on Windows.
16+
serviceDisplayName = "Elastic Agent"
17+
serviceDisplayNameDevelopmentMode = "Elastic Development Agent"
18+
)
1319

1420
var isDevelopmentMode bool
1521

@@ -49,6 +55,14 @@ func ServiceName() string {
4955
return serviceName
5056
}
5157

58+
// ServiceDisplayName returns the service display name accounting for development mode.
59+
func ServiceDisplayName() string {
60+
if IsDevelopmentMode() {
61+
return serviceDisplayNameDevelopmentMode
62+
}
63+
return serviceDisplayName
64+
}
65+
5266
// ShellWrapperPath returns the shell wrapper path accounting for development mode.
5367
func ShellWrapperPath() string {
5468
if IsDevelopmentMode() {

internal/pkg/agent/install/svc.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import (
1515
)
1616

1717
const (
18-
// ServiceDisplayName is the service display name for the service.
19-
ServiceDisplayName = "Elastic Agent"
20-
2118
// ServiceDescription is the description for the service.
2219
ServiceDescription = "Elastic Agent is a unified agent to observe, monitor and protect your system."
2320

@@ -76,7 +73,7 @@ func newService(topPath string, opt ...serviceOpt) (service.Service, error) {
7673

7774
cfg := &service.Config{
7875
Name: paths.ServiceName(),
79-
DisplayName: ServiceDisplayName,
76+
DisplayName: paths.ServiceDisplayName(),
8077
Description: ServiceDescription,
8178
Executable: ExecutablePath(topPath),
8279
WorkingDirectory: topPath,

0 commit comments

Comments
 (0)