Skip to content

Commit 7526143

Browse files
authored
Background exec (#4)
* doc: update readme * refact: remove context * ci: fix PR action * ci: change runner * ci: fix build command
1 parent 323c777 commit 7526143

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

.github/workflows/pull_request.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
name: Pull Request
22

3-
on: [pull_request, workflow_dispatch]
3+
4+
on:
5+
- pull_request
6+
- workflow_dispatch
7+
48

59
jobs:
610

711
validate:
812
runs-on:
9-
- self-hosted
10-
- ubuntu-latest
13+
- macos-latest
1114
timeout-minutes: 15
1215
steps:
1316
- name: Checkout Code
@@ -19,12 +22,11 @@ jobs:
1922
- name: Vet
2023
run: go vet ./...
2124
- name: Build
22-
run: go build -v ./cmd
25+
run: go build -v -o runsyncapps ./cmd
2326

2427
vulnerability-check:
2528
runs-on:
26-
- self-hosted
27-
- ubuntu-latest
29+
- macos-latest
2830
steps:
2931
- name: govulncheck
3032
uses: golang/govulncheck-action@v1

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
This small application allows to start multiple applications at once and if one of them is closed, the others are killed. A system tray icon allows the using to exit the application without killing the child processes.
44

5+
## Bulding
6+
7+
```shell
8+
go build -o="runsyncapps.exe" -ldflags="-H windowsgui" ./cmd/
9+
```
10+
511
## Usage
612

713
```shell

cmd/main.go

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package main
22

33
import (
4-
"context"
54
"flag"
65
"fmt"
76
"io"
87
"log/slog"
98
"os"
10-
"os/signal"
119
"path/filepath"
1210
"strings"
1311
"time"
@@ -17,15 +15,16 @@ import (
1715
)
1816

1917
const (
20-
traceFile string = "trace.log"
18+
traceFile string = "trace.log"
19+
defaultConfigFile string = "config.json"
2120
)
2221

2322
func main() {
24-
configFile := flag.String("config", "config.json", "path to a configuration file")
23+
configFile := flag.String("config", defaultConfigFile, "path to a configuration file")
2524
enableLog := flag.Bool("log", false, "enable logging")
2625
flag.Parse()
2726

28-
// Init default log handler
27+
// Init log handler
2928
var logHandler slog.Handler
3029
if *enableLog {
3130
slog.SetLogLoggerLevel(slog.LevelDebug)
@@ -36,27 +35,16 @@ func main() {
3635
logHandler = slog.NewTextHandler(io.Discard, nil)
3736
}
3837

39-
ctx := context.Background()
40-
ctx, cancel := context.WithCancel(ctx)
41-
42-
// Handle interrupt
43-
signalChan := make(chan os.Signal, 1)
44-
signal.Notify(signalChan, os.Interrupt)
45-
defer func() {
46-
signal.Stop(signalChan)
47-
cancel()
48-
}()
49-
5038
// Init systray icon
5139
go systray.Run(i.OnReadyUI, func() { os.Exit(0) })
5240

53-
if err := run(ctx, *configFile, logHandler); err != nil {
41+
if err := run(*configFile, logHandler); err != nil {
5442
fmt.Fprintf(os.Stderr, "%s\n", err)
5543
os.Exit(1)
5644
}
5745
}
5846

59-
func run(ctx context.Context, configFile string, logHandler slog.Handler) error {
47+
func run(configFile string, logHandler slog.Handler) error {
6048
logger := slog.New(logHandler)
6149

6250
config, err := i.LoadConfigFile(configFile)

0 commit comments

Comments
 (0)