From 866c6f463285bbfd135403c3577fa1b210b0d02b Mon Sep 17 00:00:00 2001 From: Hao Chen Date: Mon, 8 May 2023 15:22:37 +0800 Subject: [PATCH] Correct the document and json scheme (#346) * correct the channel example * correct the how to disable the pid file * add description how to disable sla persistent data in json scheme * correct the disable pid file description in doc and json scheme * add ~/GitHub/easeprobe configuration for pid file * refine the channel diagram * refine the channel diagram --- cmd/easeprobe/main.go | 9 +++++++-- conf/conf.go | 4 ++-- docs/Manual.md | 40 ++++++++++++++++++++-------------------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/cmd/easeprobe/main.go b/cmd/easeprobe/main.go index 9173ac4d..cdf567e4 100644 --- a/cmd/easeprobe/main.go +++ b/cmd/easeprobe/main.go @@ -102,7 +102,8 @@ func main() { } // Create the pid file if the file name is not empty - if len(strings.TrimSpace(c.Settings.PIDFile)) > 0 { + c.Settings.PIDFile = strings.TrimSpace(c.Settings.PIDFile) + if len(c.Settings.PIDFile) > 0 && c.Settings.PIDFile != "-" { d, err := daemon.NewPIDFile(c.Settings.PIDFile) if err != nil { log.Errorf("Fatal: Cannot create the PID file: %s!", err) @@ -111,7 +112,11 @@ func main() { log.Infof("Successfully created the PID file: %s", d.PIDFile) defer d.RemovePIDFile() } else { - log.Info("Skipping PID file creation (pidfile empty).") + if len(c.Settings.PIDFile) == 0 { + log.Info("Skipping PID file creation (pid file is empty).") + } else { + log.Info("Skipping PID file creation (pid file is set to '-').") + } } c.InitAllLogs() diff --git a/conf/conf.go b/conf/conf.go index f7b2b963..76a7ea34 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -109,7 +109,7 @@ type SLAReport struct { Schedule Schedule `yaml:"schedule" json:"schedule" jsonschema:"type=string,enum=none,enum=minutely,enum=hourly,enum=daily,enum=weekly,enum=monthly,title=Schedule,description=the schedule of SLA report"` Time string `yaml:"time" json:"time,omitempty" jsonschema:"format=time,title=Time,description=the time of SLA report need to send out,example=23:59:59+08:00"` //Debug bool `yaml:"debug" json:"debug,omitempty" jsonschema:"title=Debug,description=if true the SLA report will be printed to stdout,default=false"` - DataFile string `yaml:"data" json:"data,omitempty" jsonschema:"title=Data File,description=the data file of SLA report, absolute path"` + DataFile string `yaml:"data" json:"data,omitempty" jsonschema:"title=Data File,description=the data file of SLA report, absolute path. ('-' means no SLA persistent data)"` Backups int `yaml:"backups" json:"backups,omitempty" jsonschema:"title=Backups,description=the number of backups of SLA report,default=5"` Channels []string `yaml:"channels" json:"channels,omitempty" jsonschema:"title=Channels,description=the channels of SLA report"` } @@ -126,7 +126,7 @@ type HTTPServer struct { type Settings struct { Name string `yaml:"name" json:"name,omitempty" jsonschema:"title=EaseProbe Name,description=The name of the EaseProbe instance,default=EaseProbe"` IconURL string `yaml:"icon" json:"icon,omitempty" jsonschema:"title=Icon URL,description=The URL of the icon of the EaseProbe instance"` - PIDFile string `yaml:"pid" json:"pid,omitempty" jsonschema:"title=PID File,description=The PID file of the EaseProbe instance ('-' means no PID file)"` + PIDFile string `yaml:"pid" json:"pid,omitempty" jsonschema:"title=PID File,description=The PID file of the EaseProbe instance ('' or '-' means no PID file)"` Log Log `yaml:"log" json:"log,omitempty" jsonschema:"title=EaseProbe Log,description=The log settings of the EaseProbe instance"` TimeFormat string `yaml:"timeformat" json:"timeformat,omitempty" jsonschema:"title=Time Format,description=The time format of the EaseProbe instance,default=2006-01-02 15:04:05Z07:00"` TimeZone string `yaml:"timezone" json:"timezone,omitempty" jsonschema:"title=Time Zone,description=The time zone of the EaseProbe instance,example=Asia/Shanghai,example=Europe/Berlin,default=UTC"` diff --git a/docs/Manual.md b/docs/Manual.md index a6520eea..ce5b82fc 100644 --- a/docs/Manual.md +++ b/docs/Manual.md @@ -1228,34 +1228,34 @@ For example: ```YAML http: - name: probe A - channels : [ Dev_Channel, Manager_Channel ] + channels : [ Mgmt_Channel ] shell: - name: probe B - channels: [ Ops_Channel ] + channels: [ Dev_Channel, QA_Channel ] notify: - discord: Discord - channels: [ Dev_Channel, Ops_Channel ] + channels: [ Mgmt_Channel, Dev_Channel ] - email: Gmail - channels: [ Mgmt_Channel ] + channels: [ QA_Channel ] ``` Then, we will have the following diagram ``` -┌───────┐ ┌──────────────┐ -│Probe B├─────────►│ Mgmt_Channel ├────┐ -└───────┘ └──────────────┘ │ - │ - │ - ┌─────────────┐ │ ┌─────────┐ - ┌─────►│ Dev_Channel ├─────▼───► Discord │ - │ └─────────────┘ └─────────┘ -┌───────┐ │ -│Probe A├───┤ -└───────┘ │ - │ ┌────────────┐ ┌─────────┐ - └─────►│ QA_Channel ├──────────► Gmail │ - └────────────┘ └─────────┘ +┌─────────┐ ┌──────────────┐ +│ Probe A ├───────►│ Mgmt_Channel ├──────────┐ +└─────────┘ └──────────────┘ │ + http │ + │ + ┌──────────────┐ ┌────▼────┐ + ┌───►│ Dev_Channel ├────►│ Discord │ + │ └──────────────┘ └─────────┘ +┌─────────┐ │ +│ Probe B ├───┤ +└─────────┘ │ + shell │ ┌──────────────┐ ┌─────────┐ + └───►│ QA_Channel ├────►│ Gmail │ + └──────────────┘ └─────────┘ ``` # 5. Administration @@ -1274,11 +1274,11 @@ pid: /var/run/easeprobe.pid - If the file already exists, EaseProbe would overwrite it. - If the file cannot be written, EaseProbe would exit with an error. -If you want to disable the PID file, you can configure the pid file to "". +If you want to disable the PID file, you can set it to "-" or "". ```YAML settings: -pid: "" # EaseProbe won't create a PID file + pid: "" # EaseProbe won't create a PID file ``` ## 5.2 Log file Rotation