forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Elastic-Agent] Use data subfolder as default for process logs (elast…
…ic#17960) [Elastic-Agent] Use data subfolder as default for process logs (elastic#17960)
- Loading branch information
1 parent
9f3d409
commit 66f7fb9
Showing
7 changed files
with
81 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
// or more contributor license agreements. Licensed under the Elastic License; | ||
// you may not use this file except in compliance with the Elastic License. | ||
|
||
package paths | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
var ( | ||
homePath string | ||
dataPath string | ||
) | ||
|
||
func init() { | ||
exePath := retrieveExecutablePath() | ||
|
||
fs := flag.CommandLine | ||
fs.StringVar(&homePath, "path.home", exePath, "Agent root path") | ||
fs.StringVar(&dataPath, "path.data", filepath.Join(exePath, "data"), "Data path contains Agent managed binaries") | ||
} | ||
|
||
// Home returns a directory where binary lives | ||
// Executable is not supported on nacl. | ||
func Home() string { | ||
return homePath | ||
} | ||
|
||
// Data returns a home directory of current user | ||
func Data() string { | ||
return dataPath | ||
} | ||
|
||
func retrieveExecutablePath() string { | ||
|
||
execPath, err := os.Executable() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
return filepath.Dir(execPath) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters