Skip to content

Commit

Permalink
fix: loki config and goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
krzko committed Sep 29, 2024
1 parent ac67612 commit db3cdab
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 52 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ on:
- '*'

env:
GO_VERSION: "1.20"
GO_VERSION: "1.22"

jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.7
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v6
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
Expand Down
8 changes: 3 additions & 5 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# .goreleaser.yml
version: 2

before:
hooks:
- go mod tidy
Expand Down Expand Up @@ -29,9 +30,6 @@ archives:
checksum:
name_template: checksums.txt

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
filters:
Expand All @@ -43,7 +41,7 @@ changelog:

brews:
- name: run-o11y-run
tap:
repository:
owner: 'krzko'
name: 'homebrew-tap'
homepage: https://github.com/krzko/run-o11y-run
Expand Down
67 changes: 30 additions & 37 deletions internal/cli/cli.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"context"
"fmt"
"math/rand"
"os"
Expand Down Expand Up @@ -95,58 +96,50 @@ func runDockerCompose(dir, subcommand string, flags ...string) error {
args := []string{"compose", subcommand}
args = append(args, flags...)

cmd := exec.Command("docker", args...)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

cmd := exec.CommandContext(ctx, "docker", args...)
cmd.Dir = dir
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

err := cmd.Start()
if err != nil {
return fmt.Errorf("docker compose %s failed: %w", subcommand, err)
if err := cmd.Start(); err != nil {
return fmt.Errorf("docker compose %s failed to start: %w", subcommand, err)
}

if slices.Contains(args, "--detach") {
fmt.Println("🚀 Started in detached mode")
return nil
}
if subcommand == "down" {
err = cmd.Wait()
if err != nil {
return fmt.Errorf("docker compose %s failed: %w", subcommand, err)
}
} else {
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM)

done := make(chan error, 1)
go func() {
done <- cmd.Wait()
}()
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)

done := make(chan error, 1)
go func() {
done <- cmd.Wait()
}()

select {
case <-sigChan:
fmt.Printf("\nReceived interrupt signal, stopping Docker %s...\n", subcommand)
cancel()

// Wait for graceful shutdown with a timeout
select {
case <-signalChan:
fmt.Printf("Received interrupt signal, stopping Docker %s...\n", subcommand)
_ = cmd.Process.Signal(os.Interrupt)

select {
case <-signalChan:
fmt.Printf("Forcefully stopping Docker %s...\n", subcommand)
_ = cmd.Process.Kill()
os.Exit(1) // Exit with a status code of 1
case <-done:
os.Exit(0) // Exit with a status code of 0
}
case err := <-done:
if err != nil {
os.Exit(1) // Exit with a status code of 1 upon failure
}
case <-time.After(10 * time.Second):
fmt.Printf("Forcefully stopping Docker %s...\n", subcommand)
_ = cmd.Process.Kill()
case <-done:
fmt.Printf("Docker %s stopped gracefully.\n", subcommand)
}

err = <-done
return nil
case err := <-done:
if err != nil {
os.Exit(1) // Exit with a status code of 1 upon failure
return fmt.Errorf("docker compose %s failed: %w", subcommand, err)
}

return nil
}

return nil
}
9 changes: 7 additions & 2 deletions internal/files/files/grafana/run-o11y-run/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
version: "3.8"

services:

grafana:
image: grafana/grafana:11.2.0
container_name: grafana
volumes:
- ../shared/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml
# - ../shared/pyroscope/grafana-provisioning:/etc/grafana/provisioning
Expand All @@ -21,6 +20,7 @@ services:

loki:
image: grafana/loki:3.2.0
container_name: loki
command: "-config.file=/etc/loki/local-config.yaml"
environment:
- NO_PROXY=grafana,loki,minio,otel-collector,prometheus,pyroscope,tempo
Expand All @@ -40,6 +40,7 @@ services:

minio:
image: minio/minio:RELEASE.2024-09-22T00-33-43Z
container_name: minio
entrypoint:
- sh
- -euc
Expand All @@ -65,6 +66,7 @@ services:

otel-collector:
image: otel/opentelemetry-collector-contrib:0.96.0
container_name: otel-collector
command: [ "--config=/etc/otel-collector.yaml" ]
volumes:
- ../shared/otel-collector.yaml:/etc/otel-collector.yaml
Expand All @@ -83,6 +85,7 @@ services:

prometheus:
image: prom/prometheus:v2.54.1
container_name: prometheus
command:
- --config.file=/etc/prometheus.yaml
- --web.enable-remote-write-receiver
Expand All @@ -96,6 +99,7 @@ services:

pyroscope:
image: pyroscope/pyroscope:0.37.2
container_name: pyroscope
ports:
- "4040:4040"
command:
Expand All @@ -107,6 +111,7 @@ services:

tempo:
image: grafana/tempo:2.6.0
container_name: tempo
command: [ "-config.file=/etc/tempo.yaml" ]
volumes:
- ../shared/tempo.yaml:/etc/tempo.yaml
Expand Down
8 changes: 4 additions & 4 deletions internal/files/files/grafana/shared/loki.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ server:

schema_config:
configs:
- from: 2021-08-01
store: boltdb-shipper
object_store: s3
schema: v11
- from: 2020-10-24
store: tsdb
object_store: filesystem
schema: v13
index:
prefix: index_
period: 24h
Expand Down

0 comments on commit db3cdab

Please sign in to comment.