-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from ricoberger/add-preview-builds
Add preview builds
- Loading branch information
Showing
11 changed files
with
681 additions
and
584 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
name: Test | ||
steps: | ||
- name: Set up Go 1.17 | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17 | ||
id: go | ||
|
||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Get dependencies | ||
run: go mod download | ||
|
||
- name: Test | ||
run: go test ./... | ||
|
||
- name: Build | ||
run: make release | ||
|
||
- name: Upload Artifacts (darwin-amd64) | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: script_exporter-darwin-amd64 | ||
path: bin/script_exporter-darwin-amd64 | ||
if-no-files-found: error | ||
|
||
- name: Upload Artifacts (darwin-arm64) | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: script_exporter-darwin-arm64 | ||
path: bin/script_exporter-darwin-arm64 | ||
if-no-files-found: error | ||
|
||
- name: Upload Artifacts (linux-amd64) | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: script_exporter-linux-amd64 | ||
path: bin/script_exporter-linux-amd64 | ||
if-no-files-found: error | ||
|
||
- name: Upload Artifacts (linux-armv7) | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: script_exporter-linux-armv7 | ||
path: bin/script_exporter-linux-armv7 | ||
if-no-files-found: error | ||
|
||
- name: Upload Artifacts (linux-arm64) | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: script_exporter-linux-arm64 | ||
path: bin/script_exporter-linux-arm64 | ||
if-no-files-found: error | ||
|
||
- name: Upload Artifacts (windows-amd64.exe) | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: script_exporter-windows-amd64.exe | ||
path: bin/script_exporter-windows-amd64.exe | ||
if-no-files-found: error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,46 @@ | ||
// +build windows | ||
// Script_exporter is a Prometheus exporter to execute programs and | ||
// scripts and collect metrics from their output and their exit | ||
// status. | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/ricoberger/script_exporter/pkg/exporter" | ||
win "github.com/ricoberger/script_exporter/pkg/windows" | ||
"golang.org/x/sys/windows/svc" | ||
) | ||
|
||
func main() { | ||
e := exporter.InitExporter() | ||
|
||
isInteractive, err := svc.IsAnInteractiveSession() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
stopCh := make(chan bool) | ||
if !isInteractive { | ||
go func() { | ||
err = svc.Run("Script Exporter", win.NewWindowsExporterService(stopCh)) | ||
if err != nil { | ||
log.Fatalf("Failed to start service: %v", err) | ||
} | ||
}() | ||
} | ||
|
||
go func() { | ||
e.Serve() | ||
}() | ||
|
||
for { | ||
if <-stopCh { | ||
log.Printf("Shutting down %s", "Script Exporter") | ||
break | ||
} | ||
} | ||
|
||
} | ||
//go:build windows | ||
// +build windows | ||
|
||
// Script_exporter is a Prometheus exporter to execute programs and | ||
// scripts and collect metrics from their output and their exit | ||
// status. | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/ricoberger/script_exporter/pkg/exporter" | ||
win "github.com/ricoberger/script_exporter/pkg/windows" | ||
"golang.org/x/sys/windows/svc" | ||
) | ||
|
||
func main() { | ||
e := exporter.InitExporter() | ||
|
||
isInteractive, err := svc.IsAnInteractiveSession() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
stopCh := make(chan bool) | ||
if !isInteractive { | ||
go func() { | ||
err = svc.Run("Script Exporter", win.NewWindowsExporterService(stopCh)) | ||
if err != nil { | ||
log.Fatalf("Failed to start service: %v", err) | ||
} | ||
}() | ||
} | ||
|
||
go func() { | ||
e.Serve() | ||
}() | ||
|
||
for { | ||
if <-stopCh { | ||
log.Printf("Shutting down %s", "Script Exporter") | ||
break | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
module github.com/ricoberger/script_exporter | ||
|
||
go 1.17 | ||
|
||
require ( | ||
github.com/golang-jwt/jwt v3.2.2+incompatible | ||
github.com/prometheus/client_golang v1.11.0 | ||
golang.org/x/sys v0.0.0-20210909193231-528a39cd75f3 | ||
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0 | ||
gopkg.in/yaml.v2 v2.4.0 | ||
) | ||
|
||
go 1.16 | ||
require ( | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.1.1 // indirect | ||
github.com/golang/protobuf v1.4.3 // indirect | ||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect | ||
github.com/prometheus/client_model v0.2.0 // indirect | ||
github.com/prometheus/common v0.26.0 // indirect | ||
github.com/prometheus/procfs v0.6.0 // indirect | ||
google.golang.org/protobuf v1.26.0-rc.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.