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
|
- uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
cache: true
|
|
||||||
|
|
||||||
- run: |
|
- run: |
|
||||||
go install golang.org/x/tools/cmd/goimports@latest
|
go install golang.org/x/tools/cmd/goimports@latest
|
||||||
@@ -29,6 +28,27 @@ jobs:
|
|||||||
|
|
||||||
- uses: pre-commit/action@v3.0.0
|
- 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:
|
build:
|
||||||
name: Build & Unit Test
|
name: Build & Unit Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -39,12 +59,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
go-version: ${{ env.GO_VERSION }}
|
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 env
|
||||||
|
|
||||||
- run: go install ./cmd/litestream
|
- run: go install ./cmd/litestream
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@@ -37,16 +36,16 @@ func runWindowsService(ctx context.Context) error {
|
|||||||
defer elog.Close()
|
defer elog.Close()
|
||||||
|
|
||||||
// Set eventlog as log writer while running.
|
// Set eventlog as log writer while running.
|
||||||
log.SetOutput((*eventlogWriter)(elog))
|
slog.SetDefault(slog.New(slog.NewTextHandler((*eventlogWriter)(elog), nil)))
|
||||||
defer log.SetOutput(os.Stderr)
|
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 {
|
if err := svc.Run(serviceName, &windowsService{ctx: ctx}); err != nil {
|
||||||
return errStop
|
return errStop
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Print("Litestream service stopped")
|
slog.Info("Litestream service stopped")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +68,7 @@ func (s *windowsService) Execute(args []string, r <-chan svc.ChangeRequest, stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Execute replication command.
|
// Execute replication command.
|
||||||
if err := c.Run(s.ctx); err != nil {
|
if err := c.Run(); err != nil {
|
||||||
slog.Error("cannot replicate", "error", err)
|
slog.Error("cannot replicate", "error", err)
|
||||||
statusCh <- svc.Status{State: svc.StopPending}
|
statusCh <- svc.Status{State: svc.StopPending}
|
||||||
return true, 2
|
return true, 2
|
||||||
|
|||||||
Reference in New Issue
Block a user