-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Justin Kolberg <[email protected]>
- Loading branch information
1 parent
fb94e90
commit 17a2d06
Showing
12 changed files
with
226 additions
and
17 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
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
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,54 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"io/fs" | ||
|
||
"howett.net/plist" | ||
) | ||
|
||
const ( | ||
launchdConfigPlist = "com.sumologic.otelcol-sumo.plist" | ||
) | ||
|
||
type launchdConfig struct { | ||
Format int | ||
Root launchdRoot | ||
} | ||
|
||
type launchdRoot struct { | ||
Label string `plist:"Label"` | ||
ProgramArguments []string `plist:"ProgramArguments"` | ||
EnvironmentVariables map[string]string `plist:"EnvironmentVariables"` | ||
UserName string `plist:"UserName"` | ||
GroupName string `plist:"GroupName"` | ||
RunAtLoad bool `plist:"RunAtLoad"` | ||
KeepAlive bool `plist:"KeepAlive"` | ||
StandardOutPath string `plist:"StandardOutPath"` | ||
StandardErrorPath string `plist:"StandardErrorPath"` | ||
} | ||
|
||
// ReadLaunchdConfig reads and unmarshals the launchd config from | ||
// /Library/LaunchDaemons/com.sumologic.otelcol-sumo.plist. It produces a | ||
// launchdConfig that contains the data read from the launchd config. | ||
func ReadLaunchdConfig(root fs.FS) (launchdConfig, error) { | ||
const errMsg = "" | ||
|
||
conf := launchdConfig{} | ||
|
||
bytes, err := fs.ReadFile(root, launchdConfigPlist) | ||
if err != nil { | ||
return conf, fmt.Errorf("error reading launchd config: %s", err) | ||
} | ||
|
||
confRoot := launchdRoot{} | ||
format, err := plist.Unmarshal(bytes, &confRoot) | ||
if err != nil { | ||
return conf, fmt.Errorf("error unmarshaling launchd config: %s", err) | ||
} | ||
|
||
conf.Format = format | ||
conf.Root = confRoot | ||
|
||
return conf, nil | ||
} |
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,40 @@ | ||
package main | ||
|
||
const xmlPreamble = `<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
` | ||
|
||
var defaultLaunchdConfigXML = xmlPreamble + | ||
`<plist version="1.0">` + | ||
`<dict>` + | ||
`<key>Label</key>` + | ||
`<string>otelcol-sumo</string>` + | ||
`<key>ProgramArguments</key>` + | ||
`<array>` + | ||
`<string>/usr/share/otelcol-sumo.sh</string>` + | ||
`</array>` + | ||
`<key>EnvironmentVariables</key>` + | ||
`<dict>` + | ||
`<key>SUMOLOGIC_INSTALLATION_TOKEN</key>` + | ||
`<string></string>` + | ||
`</dict>` + | ||
`<!-- Service user -->` + | ||
`<key>UserName</key>` + | ||
`<string>_otelcol-sumo</string>` + | ||
`<!-- Service group -->` + | ||
`<key>GroupName</key>` + | ||
`<string>_otelcol-sumo</string>` + | ||
`<!-- Run the service immediately after it is loaded -->` + | ||
`<key>RunAtLoad</key>` + | ||
`<true/>` + | ||
`<!-- Restart the process if it exits -->` + | ||
`<key>KeepAlive</key>` + | ||
`<true/>` + | ||
`<!-- Redirect stdout to a log file -->` + | ||
`<key>StandardOutPath</key>` + | ||
`<string>/var/log/otelcol-sumo/otelcol-sumo.log</string>` + | ||
`<!-- Redirect stderr to a log file -->` + | ||
`<key>StandardErrorPath</key>` + | ||
`<string>/var/log/otelcol-sumo/otelcol-sumo.log</string>` + | ||
`</dict>` + | ||
`</plist>` |
Oops, something went wrong.