mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-18 18:56:35 +00:00
fix: use log.file=eventlog as default value, if running as windows service (#1771)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -105,7 +105,14 @@ func run() int {
|
|||||||
).Default("normal").String()
|
).Default("normal").String()
|
||||||
)
|
)
|
||||||
|
|
||||||
logConfig := &log.Config{}
|
logFile := &log.AllowedFile{}
|
||||||
|
|
||||||
|
_ = logFile.Set("stdout")
|
||||||
|
if windowsservice.IsService {
|
||||||
|
_ = logFile.Set("eventlog")
|
||||||
|
}
|
||||||
|
|
||||||
|
logConfig := &log.Config{File: logFile}
|
||||||
flag.AddFlags(app, logConfig)
|
flag.AddFlags(app, logConfig)
|
||||||
|
|
||||||
app.Version(version.Print("windows_exporter"))
|
app.Version(version.Print("windows_exporter"))
|
||||||
|
|||||||
@@ -13,8 +13,8 @@
|
|||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
|
<Wix xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
|
||||||
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
|
xmlns="http://wixtoolset.org/schemas/v4/wxs">
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<DirectoryRef Id="APPLICATIONFOLDER">
|
<DirectoryRef Id="APPLICATIONFOLDER">
|
||||||
<Component Transitive="yes">
|
<Component Transitive="yes">
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
Start="auto"
|
Start="auto"
|
||||||
Type="ownProcess"
|
Type="ownProcess"
|
||||||
Vital="yes"
|
Vital="yes"
|
||||||
Arguments="--log.file eventlog [ConfigFileFlag] [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirsFlag] [ExtraFlags]">
|
Arguments="[ConfigFileFlag] [CollectorsFlag] [ListenFlag] [MetricsPathFlag] [TextfileDirsFlag] [ExtraFlags]">
|
||||||
<util:ServiceConfig
|
<util:ServiceConfig
|
||||||
ResetPeriodInDays="1"
|
ResetPeriodInDays="1"
|
||||||
FirstFailureActionType="restart"
|
FirstFailureActionType="restart"
|
||||||
|
|||||||
@@ -24,9 +24,9 @@
|
|||||||
~ limitations under the License.
|
~ limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
|
<Wix xmlns:fw="http://wixtoolset.org/schemas/v4/wxs/firewall"
|
||||||
xmlns:fw="http://wixtoolset.org/schemas/v4/wxs/firewall"
|
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui"
|
||||||
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
|
xmlns="http://wixtoolset.org/schemas/v4/wxs">
|
||||||
<Package UpgradeCode="66a6eb5b-1fc2-4b14-a362-5ceec6413308" Name="$(var.ProductName)" Version="$(var.Version)"
|
<Package UpgradeCode="66a6eb5b-1fc2-4b14-a362-5ceec6413308" Name="$(var.ProductName)" Version="$(var.Version)"
|
||||||
Manufacturer="prometheus-community" Language="1033" Scope="perMachine">
|
Manufacturer="prometheus-community" Language="1033" Scope="perMachine">
|
||||||
<SummaryInformation Manufacturer="prometheus-community" Description="$(var.ProductName) $(var.Version) installer" />
|
<SummaryInformation Manufacturer="prometheus-community" Description="$(var.ProductName) $(var.Version) installer" />
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ func AddFlags(a *kingpin.Application, config *log.Config) {
|
|||||||
config.Config = new(promslog.Config)
|
config.Config = new(promslog.Config)
|
||||||
flag.AddFlags(a, config.Config)
|
flag.AddFlags(a, config.Config)
|
||||||
|
|
||||||
config.File = &log.AllowedFile{}
|
if config.File == nil {
|
||||||
a.Flag(FileFlagName, FileFlagHelp).Default("stderr").SetValue(config.File)
|
config.File = &log.AllowedFile{}
|
||||||
|
}
|
||||||
|
|
||||||
|
a.Flag(FileFlagName, FileFlagHelp).Default(config.File.String()).SetValue(config.File)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ type AllowedFile struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *AllowedFile) String() string {
|
func (f *AllowedFile) String() string {
|
||||||
|
if f == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
return f.s
|
return f.s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user