@@ -58,17 +58,18 @@ const (
58
58
var ExternalInputsPattern = filepath .Join ("inputs.d" , "*.yml" )
59
59
60
60
var (
61
- topPath string
62
- configPath string
63
- configFilePath string
64
- logsPath string
65
- downloadsPath string
66
- componentsPath string
67
- installPath string
68
- controlSocketPath string
69
- edotSocketPath string
70
- unversionedHome bool
71
- tmpCreator sync.Once
61
+ topPath string
62
+ configPath string
63
+ configFilePath string
64
+ logsPath string
65
+ downloadsPath string
66
+ componentsPath string
67
+ installPath string
68
+ controlSocketPath string
69
+ edotSocketPath string
70
+ diagnosticsExtensionSocket string
71
+ unversionedHome bool
72
+ tmpCreator sync.Once
72
73
)
73
74
74
75
func init () {
@@ -77,7 +78,8 @@ func init() {
77
78
configPath = topPath
78
79
logsPath = topPath
79
80
controlSocketPath = initialControlSocketPath (topPath )
80
- edotSocketPath = EDOTSocketFromPath (runtime .GOOS , topPath )
81
+ edotSocketPath = SocketFromPath (runtime .GOOS , topPath , EDOTSocketName )
82
+ diagnosticsExtensionSocket = SocketFromPath (runtime .GOOS , topPath , DiagnosticsExtensionSocketName )
81
83
unversionedHome = false // only versioned by container subcommand
82
84
83
85
// these should never change
@@ -93,6 +95,7 @@ func init() {
93
95
fs .StringVar (& configFilePath , "c" , DefaultConfigName , "Configuration file, relative to path.config" )
94
96
fs .StringVar (& logsPath , "path.logs" , logsPath , "Logs path contains Agent log output" )
95
97
fs .StringVar (& controlSocketPath , "path.socket" , controlSocketPath , "Control protocol socket path for the Agent" )
98
+ fs .StringVar (& edotSocketPath , "path.edot_socket" , edotSocketPath , "Control protocol socket path for the EDOT" )
96
99
97
100
// enable user to download update artifacts to alternative place
98
101
// TODO: remove path.downloads support on next major (this can be configured using `agent.download.targetDirectory`)
@@ -352,27 +355,14 @@ func RunningInstalled() bool {
352
355
// ControlSocketFromPath returns the control socket path for an Elastic Agent running
353
356
// on the defined platform, and its executing directory.
354
357
func ControlSocketFromPath (platform string , path string ) string {
355
- // socket should be inside this directory
356
- socketPath := filepath .Join (path , ControlSocketName )
357
- if platform == "windows" {
358
- // on windows the control socket always uses the fallback
359
- return utils .SocketURLWithFallback (socketPath , path )
360
- }
361
- unixSocket := fmt .Sprintf ("unix://%s" , socketPath )
362
- if len (unixSocket ) < 104 {
363
- // small enough to fit
364
- return unixSocket
365
- }
366
- // place in global /tmp to ensure that its small enough to fit; current path is way to long
367
- // for it to be used, but needs to be unique per Agent (in the case that multiple are running)
368
- return utils .SocketURLWithFallback (socketPath , path )
358
+ return SocketFromPath (platform , path , ControlSocketName )
369
359
}
370
360
371
- // EDOTSocketFromPath returns the EDOT socket path for an Elastic Agent running
372
- // on the defined platform, and its executing directory.
373
- func EDOTSocketFromPath (platform string , path string ) string {
361
+ // SocketFromPath returns the socket path for an Elastic Agent running
362
+ // on the defined platform for a given socket , and its executing directory.
363
+ func SocketFromPath (platform string , path string , socketName string ) string {
374
364
// socket should be inside this directory
375
- socketPath := filepath .Join (path , EDOTSocketName )
365
+ socketPath := filepath .Join (path , socketName )
376
366
if platform == "windows" {
377
367
// on windows the control socket always uses the fallback
378
368
return utils .SocketURLWithFallback (socketPath , path )
@@ -388,7 +378,11 @@ func EDOTSocketFromPath(platform string, path string) string {
388
378
}
389
379
390
380
func DiagnosticsExtensionSocket () string {
391
- return filepath .Join (topPath , DiagnosticsExtensionSocketName )
381
+ return diagnosticsExtensionSocket
382
+ }
383
+
384
+ func SetDiagnosticsExtensionSocket (socket string ) {
385
+ diagnosticsExtensionSocket = SocketFromPath (runtime .GOOS , topPath , socket )
392
386
}
393
387
394
388
func pathSplit (path string ) []string {
0 commit comments