mirror of
https://github.com/F1bonacc1/process-compose.git
synced 2024-08-16 15:00:32 +03:00
Log level support
This commit is contained in:
parent
f50a43098b
commit
11819ea852
15
README.md
15
README.md
@ -1,8 +1,8 @@
|
||||
## Process Compose
|
||||
|
||||
[![made-with-Go](https://img.shields.io/badge/Made%20with-Go-1f425f.svg)](https://go.dev/) [![Linux](https://svgshare.com/i/Zhy.svg)](https://svgshare.com/i/Zhy.svg) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
|
||||
[![made-with-Go](https://img.shields.io/badge/Made%20with-Go-1f425f.svg)](https://go.dev/) [![Linux](https://svgshare.com/i/Zhy.svg)](https://svgshare.com/i/Zhy.svg) [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) ![Go Report](https://goreportcard.com/badge/github.com/F1bonacc1/process-compose)
|
||||
|
||||
Process compose is a small utility for building custom workflows and execution sequences. It is optimized for:
|
||||
Process compose is a lightweight utility for building custom workflows and execution sequences. It is optimized for:
|
||||
|
||||
* Parallelizing processes execution
|
||||
* Defining execution dependencies and order
|
||||
@ -112,6 +112,17 @@ log_location: ./pc.global.log #if undefined or empty no logs will be saved (if a
|
||||
|
||||
##### ❌ Silence specific processes
|
||||
|
||||
##### ✅ Process compose console log level
|
||||
|
||||
```yaml
|
||||
log_level: info # other options: "trace", "debug", "info", "warn", "error", "fatal", "panic"
|
||||
processes:
|
||||
process2:
|
||||
command: "chmod 666 /path/to/file"
|
||||
```
|
||||
|
||||
This setting controls the `process-compose` log level. The processes log level should be defined inside the process. It is recommended to support its definition with an environment variable that can be defined in `process-compose.yaml`
|
||||
|
||||
|
||||
|
||||
#### ❌ <u>Health Checks</u>
|
||||
|
@ -1,9 +1,10 @@
|
||||
version: "0.5"
|
||||
log_level: "undefined"
|
||||
processes:
|
||||
process1:
|
||||
command: "echo process1"
|
||||
depends_on:
|
||||
process2:
|
||||
process2:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process2:
|
||||
@ -11,13 +12,13 @@ processes:
|
||||
availability:
|
||||
restart: "on-failure"
|
||||
depends_on:
|
||||
process3:
|
||||
process3:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process3:
|
||||
command: "echo 'process3 error' >&2 && exit 1"
|
||||
depends_on:
|
||||
process4:
|
||||
process4:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process4:
|
||||
@ -25,7 +26,7 @@ processes:
|
||||
availability:
|
||||
restart: "on-failure"
|
||||
depends_on:
|
||||
process5:
|
||||
process5:
|
||||
condition: process_completed
|
||||
|
||||
process5:
|
||||
@ -35,7 +36,7 @@ processes:
|
||||
backoff_seconds: 1
|
||||
max_restarts: 1
|
||||
depends_on:
|
||||
process6:
|
||||
process6:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process6:
|
||||
@ -45,7 +46,7 @@ processes:
|
||||
backoff_seconds: 2
|
||||
max_restarts: 1
|
||||
depends_on:
|
||||
process7:
|
||||
process7:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process7:
|
||||
@ -53,7 +54,7 @@ processes:
|
||||
availability:
|
||||
restart: "on-failure"
|
||||
depends_on:
|
||||
process8:
|
||||
process8:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process8:
|
||||
@ -63,7 +64,7 @@ processes:
|
||||
backoff_seconds: 2
|
||||
|
||||
|
||||
|
||||
|
||||
environment:
|
||||
- 'ABC=222'
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
version: "0.5"
|
||||
log_level: info
|
||||
processes:
|
||||
process1:
|
||||
command: "echo process1"
|
||||
depends_on:
|
||||
process2:
|
||||
process2:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process2:
|
||||
@ -11,13 +12,13 @@ processes:
|
||||
availability:
|
||||
restart: "on-failure"
|
||||
depends_on:
|
||||
process3:
|
||||
process3:
|
||||
condition: process_completed
|
||||
|
||||
process3:
|
||||
command: "echo 'process3 error' >&2 && exit 1"
|
||||
depends_on:
|
||||
process4:
|
||||
process4:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process4:
|
||||
@ -25,7 +26,7 @@ processes:
|
||||
availability:
|
||||
restart: "on-failure"
|
||||
depends_on:
|
||||
process5:
|
||||
process5:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process5:
|
||||
@ -34,7 +35,7 @@ processes:
|
||||
restart: "on-failure"
|
||||
backoff_seconds: 2
|
||||
depends_on:
|
||||
process6:
|
||||
process6:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process6:
|
||||
@ -43,7 +44,7 @@ processes:
|
||||
restart: "on-failure"
|
||||
log_location: ./pc.proc6.log-test.log
|
||||
depends_on:
|
||||
process7:
|
||||
process7:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process7:
|
||||
@ -51,7 +52,7 @@ processes:
|
||||
availability:
|
||||
restart: "on-failure"
|
||||
depends_on:
|
||||
process8:
|
||||
process8:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process8:
|
||||
@ -61,7 +62,7 @@ processes:
|
||||
backoff_seconds: 2
|
||||
|
||||
|
||||
|
||||
|
||||
environment:
|
||||
- 'ABC=222'
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
version: "0.5"
|
||||
log_level: debug
|
||||
processes:
|
||||
process0:
|
||||
command: "ls ddd"
|
||||
@ -9,11 +10,11 @@ processes:
|
||||
restart: "on-failure"
|
||||
backoff_seconds: 2
|
||||
depends_on:
|
||||
process2:
|
||||
process2:
|
||||
condition: process_completed_successfully
|
||||
process3:
|
||||
process3:
|
||||
condition: process_completed
|
||||
# process4:
|
||||
# process4:
|
||||
# condition: process_completed_successfully
|
||||
environment:
|
||||
- 'EXIT_CODE=0'
|
||||
@ -24,7 +25,7 @@ processes:
|
||||
availability:
|
||||
restart: "on-failure"
|
||||
# depends_on:
|
||||
# process3:
|
||||
# process3:
|
||||
# condition: process_completed_successfully
|
||||
environment:
|
||||
- 'ABC=2221'
|
||||
@ -37,7 +38,7 @@ processes:
|
||||
restart: "on-failure"
|
||||
backoff_seconds: 2
|
||||
depends_on:
|
||||
process4:
|
||||
process4:
|
||||
condition: process_completed_successfully
|
||||
|
||||
process4:
|
||||
|
@ -5,6 +5,7 @@ import "sync"
|
||||
type Project struct {
|
||||
Version string `yaml:"version"`
|
||||
LogLocation string `yaml:"log_location,omitempty"`
|
||||
LogLevel string `yaml:"log_level,omitempty"`
|
||||
Processes Processes `yaml:"processes"`
|
||||
Environment []string `yaml:"environment,omitempty"`
|
||||
|
||||
|
10
src/main.go
10
src/main.go
@ -38,7 +38,16 @@ func createProject(inputFile string) *Project {
|
||||
if err != nil {
|
||||
log.Fatal().Msg(err.Error())
|
||||
}
|
||||
if project.LogLevel != "" {
|
||||
lvl, err := zerolog.ParseLevel(project.LogLevel)
|
||||
if err != nil {
|
||||
log.Error().Msgf("Unknown log level %s defaulting to %s",
|
||||
project.LogLevel, zerolog.GlobalLevel().String())
|
||||
} else {
|
||||
zerolog.SetGlobalLevel(lvl)
|
||||
}
|
||||
|
||||
}
|
||||
return &project
|
||||
}
|
||||
|
||||
@ -48,6 +57,7 @@ func setupLogger() {
|
||||
Out: os.Stdout,
|
||||
TimeFormat: "06-01-02 15:04:05",
|
||||
})
|
||||
zerolog.SetGlobalLevel(zerolog.InfoLevel)
|
||||
}
|
||||
|
||||
func findFiles(names []string, pwd string) []string {
|
||||
|
Loading…
Reference in New Issue
Block a user