Browse Source

Include geodns-logs in new archives/packages

Ask Bjørn Hansen 4 years ago
parent
commit
1e75f332e0
5 changed files with 51 additions and 16 deletions
  1. 2 2
      .drone.yml
  2. 22 8
      .goreleaser.yml
  3. 6 6
      geodns-logs/process-stats.go
  4. 4 0
      service-logs/log/run
  5. 17 0
      service-logs/run

+ 2 - 2
.drone.yml

@@ -38,10 +38,10 @@ steps:
     image: golang:1.16.7
     image: golang:1.16.7
     resources:
     resources:
       requests:
       requests:
-        cpu: 3000
+        cpu: 4000
         memory: 512MiB
         memory: 512MiB
       limits:
       limits:
-        cpu: 6000
+        cpu: 10000
         memory: 2048MiB
         memory: 2048MiB
     volumes:
     volumes:
       - name: cache
       - name: cache

+ 22 - 8
.goreleaser.yml

@@ -11,7 +11,22 @@ builds:
       - -X main.VERSION={{.Version}}
       - -X main.VERSION={{.Version}}
       - -X main.gitVersion={{.ShortCommit}}
       - -X main.gitVersion={{.ShortCommit}}
       - -X main.buildTime={{.Date}}
       - -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:
     goos:
       - linux
       - linux
       - freebsd
       - freebsd
@@ -24,12 +39,11 @@ builds:
       - goos: freebsd
       - goos: freebsd
         goarch: arm64
         goarch: arm64
 archives:
 archives:
-  - replacements:
-      #darwin: Darwin
-      #linux: Linux
-      #windows: Windows
-      #386: i386
-      #amd64: x86_64
+  - files:
+      - service/**
+      - service-logs/**
+      - LICENSE
+      - README.md
 checksum:
 checksum:
   name_template: "checksums.txt"
   name_template: "checksums.txt"
 snapshot:
 snapshot:
@@ -52,7 +66,7 @@ nfpms:
 
 
     # You can change the file name of the package.
     # You can change the file name of the package.
     # Default: `{{ .PackageName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}`
     # 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
     vendor: NTP Pool Project
     homepage: https://www.ntppool.org/
     homepage: https://www.ntppool.org/

+ 6 - 6
geodns-logs/process-stats.go

@@ -23,11 +23,11 @@ import (
 // Add vendor yes/no
 // Add vendor yes/no
 // add server region tag (identifier)?
 // add server region tag (identifier)?
 
 
-const userAgent = "geodns-logs/2.0"
+var version string = "2.1"
 
 
 func main() {
 func main() {
 
 
-	log.Printf("Starting %q", userAgent)
+	log.Printf("Starting geodns-logs/%q", version)
 
 
 	identifierFlag := flag.String("identifier", "", "identifier (hostname, pop name or similar)")
 	identifierFlag := flag.String("identifier", "", "identifier (hostname, pop name or similar)")
 	// verboseFlag := flag.Bool("verbose", false, "verbose output")
 	// verboseFlag := flag.Bool("verbose", false, "verbose output")
@@ -39,9 +39,9 @@ func main() {
 	if len(*identifierFlag) > 0 {
 	if len(*identifierFlag) > 0 {
 		ids := strings.Split(*identifierFlag, ",")
 		ids := strings.Split(*identifierFlag, ",")
 		serverID = ids[0]
 		serverID = ids[0]
-		if len(ids) > 1 {
-			// serverGroups = ids[1:]
-		}
+		// if len(ids) > 1 {
+		// serverGroups = ids[1:]
+		// }
 	}
 	}
 
 
 	if len(serverID) == 0 {
 	if len(serverID) == 0 {
@@ -70,7 +70,7 @@ func main() {
 		[]string{"Version"},
 		[]string{"Version"},
 	)
 	)
 	prometheus.MustRegister(buildInfo)
 	prometheus.MustRegister(buildInfo)
-	buildInfo.WithLabelValues(userAgent).Set(1)
+	buildInfo.WithLabelValues("geodns-logs/" + version).Set(1)
 
 
 	http.Handle("/metrics", promhttp.Handler())
 	http.Handle("/metrics", promhttp.Handler())
 	go func() {
 	go func() {

+ 4 - 0
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 - 0
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