Skip to content

Commit

Permalink
Include geodns-logs in new archives/packages
Browse files Browse the repository at this point in the history
  • Loading branch information
abh committed Aug 8, 2021
1 parent ab95b55 commit 1e75f33
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .drone.yml
Expand Up @@ -38,10 +38,10 @@ steps:
image: golang:1.16.7
resources:
requests:
cpu: 3000
cpu: 4000
memory: 512MiB
limits:
cpu: 6000
cpu: 10000
memory: 2048MiB
volumes:
- name: cache
Expand Down
30 changes: 22 additions & 8 deletions .goreleaser.yml
Expand Up @@ -11,7 +11,22 @@ builds:
- -X main.VERSION={{.Version}}
- -X main.gitVersion={{.ShortCommit}}
- -X main.buildTime={{.Date}}

goos:
- linux
- freebsd
- darwin
ignore:
- goos: darwin
goarch: 386
- goos: freebsd
goarch: 386
- goos: freebsd
goarch: arm64
- id: geodns-logs
main: ./geodns-logs/
binary: geodns-logs
env:
- CGO_ENABLED=0
goos:
- linux
- freebsd
Expand All @@ -24,12 +39,11 @@ builds:
- goos: freebsd
goarch: arm64
archives:
- replacements:
#darwin: Darwin
#linux: Linux
#windows: Windows
#386: i386
#amd64: x86_64
- files:
- service/**
- service-logs/**
- LICENSE
- README.md
checksum:
name_template: "checksums.txt"
snapshot:
Expand All @@ -52,7 +66,7 @@ nfpms:

# You can change the file name of the package.
# Default: `{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}`
file_name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

vendor: NTP Pool Project
homepage: https://www.ntppool.org/
Expand Down
12 changes: 6 additions & 6 deletions geodns-logs/process-stats.go
Expand Up @@ -23,11 +23,11 @@ import (
// Add vendor yes/no
// add server region tag (identifier)?

const userAgent = "geodns-logs/2.0"
var version string = "2.1"

func main() {

log.Printf("Starting %q", userAgent)
log.Printf("Starting geodns-logs/%q", version)

identifierFlag := flag.String("identifier", "", "identifier (hostname, pop name or similar)")
// verboseFlag := flag.Bool("verbose", false, "verbose output")
Expand All @@ -39,9 +39,9 @@ func main() {
if len(*identifierFlag) > 0 {
ids := strings.Split(*identifierFlag, ",")
serverID = ids[0]
if len(ids) > 1 {
// serverGroups = ids[1:]
}
// if len(ids) > 1 {
// serverGroups = ids[1:]
// }
}

if len(serverID) == 0 {
Expand Down Expand Up @@ -70,7 +70,7 @@ func main() {
[]string{"Version"},
)
prometheus.MustRegister(buildInfo)
buildInfo.WithLabelValues(userAgent).Set(1)
buildInfo.WithLabelValues("geodns-logs/" + version).Set(1)

http.Handle("/metrics", promhttp.Handler())
go func() {
Expand Down
4 changes: 4 additions & 0 deletions service-logs/log/run
@@ -0,0 +1,4 @@
#!/bin/sh
mkdir -p /var/log/geodns-logs
chown nobody /var/log/geodns-logs
exec setuidgid nobody multilog s10000000 n3 /var/log/geodns-logs
17 changes: 17 additions & 0 deletions service-logs/run
@@ -0,0 +1,17 @@
#!/bin/sh
exec 2>&1
sleep 1 # just in case we spin for some reason

cd /opt/geodns

ulimit -n 8192

ID=""
if [ -e env/ID ]; then
ID=`head -1 env/ID`
if [ ! -z "$ID" ]; then
ID="--identifier=$ID"
fi
fi

exec softlimit -d200000000 envdir ./env setuidgid nobody ./geodns-logs $ID /var/log/geodns/queries.log

0 comments on commit 1e75f33

Please sign in to comment.