Fix Windows builds and test they compile (#543)
This commit is contained in:
28
.github/workflows/commit.yml
vendored
28
.github/workflows/commit.yml
vendored
@@ -20,7 +20,6 @@ jobs:
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
cache: true
|
||||
|
||||
- run: |
|
||||
go install golang.org/x/tools/cmd/goimports@latest
|
||||
@@ -29,6 +28,27 @@ jobs:
|
||||
|
||||
- uses: pre-commit/action@v3.0.0
|
||||
|
||||
build-windows:
|
||||
name: Build Windows
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- run: sudo apt-get install -y mingw-w64
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- run: |
|
||||
go build ./cmd/litestream/
|
||||
file ./litestream.exe
|
||||
env:
|
||||
CGO_ENABLED: "1"
|
||||
GOOS: windows
|
||||
GOARCH: amd64
|
||||
CC: x86_64-w64-mingw32-gcc
|
||||
|
||||
build:
|
||||
name: Build & Unit Test
|
||||
runs-on: ubuntu-latest
|
||||
@@ -39,12 +59,6 @@ jobs:
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/go/pkg/mod
|
||||
key: ${{ inputs.os }}-go-${{ hashFiles('**/go.sum') }}
|
||||
restore-keys: ${{ inputs.os }}-go-
|
||||
|
||||
- run: go env
|
||||
|
||||
- run: go install ./cmd/litestream
|
||||
|
||||
@@ -5,7 +5,6 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"log"
|
||||
"log/slog"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -37,16 +36,16 @@ func runWindowsService(ctx context.Context) error {
|
||||
defer elog.Close()
|
||||
|
||||
// Set eventlog as log writer while running.
|
||||
log.SetOutput((*eventlogWriter)(elog))
|
||||
defer log.SetOutput(os.Stderr)
|
||||
slog.SetDefault(slog.New(slog.NewTextHandler((*eventlogWriter)(elog), nil)))
|
||||
defer slog.SetDefault(slog.New(slog.NewTextHandler(os.Stderr, nil)))
|
||||
|
||||
log.Print("Litestream service starting")
|
||||
slog.Info("Litestream service starting")
|
||||
|
||||
if err := svc.Run(serviceName, &windowsService{ctx: ctx}); err != nil {
|
||||
return errStop
|
||||
}
|
||||
|
||||
log.Print("Litestream service stopped")
|
||||
slog.Info("Litestream service stopped")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -69,7 +68,7 @@ func (s *windowsService) Execute(args []string, r <-chan svc.ChangeRequest, stat
|
||||
}
|
||||
|
||||
// Execute replication command.
|
||||
if err := c.Run(s.ctx); err != nil {
|
||||
if err := c.Run(); err != nil {
|
||||
slog.Error("cannot replicate", "error", err)
|
||||
statusCh <- svc.Status{State: svc.StopPending}
|
||||
return true, 2
|
||||
|
||||
Reference in New Issue
Block a user