A tool to run a group of instances of the same command in gokrazy.
Gokrazy's PackageConfig
is a map keyed by package path, which means it is only
possible to have one configuration entry per package. This becomes a limitation
when the same package or command needs to be run multiple times with different
arguments, like running both tailscale up
and tailscale serve
.
gokrazy-cmdgroup
solves this by providing a single command that can manage and
supervise a group of instances of the same command.
Features:
- Run multiple instances of the same command with different arguments
- Optional automatic restarting of instances when they exit (
-watch
) - Process group management for clean shutdowns
Add the cmdgroup package to your gokrazy configuration:
gok add github.com/tho/gokrazy-cmdgroup/cmd/cmdgroup
or
"Packages": [
"github.com/tho/gokrazy-cmdgroup/cmd/cmdgroup"
]
Configure it with command line flags:
"PackageConfig": {
"github.com/tho/gokrazy-cmdgroup/cmd/cmdgroup": {
"CommandLineFlags": [
"-name",
"command",
"--",
"arg1",
"-flag1",
"--",
"arg2",
"-flag2"
]
}
}
-name
: The command to run-watch
: Control which instances to restart on exitnone
: Don't restart any instance (default)all
: Restart all instances when they exit0,1
: Restart instances 0 and 1
- Separate arguments for each instance with
--
Run both tailscale up
and tailscale serve
:
{
"Hostname": "ts",
"Packages": [
"tailscale.com/cmd/tailscale",
"tailscale.com/cmd/tailscaled",
"github.com/tho/gokrazy-cmdgroup/cmd/cmdgroup"
],
"PackageConfig": {
"github.com/tho/gokrazy-cmdgroup/cmd/cmdgroup": {
"CommandLineFlags": [
"-name",
"/user/tailscale",
"--",
"up",
"--auth-key=file:/etc/tailscale/auth_key",
"--",
"serve",
"text:hello"
],
"ExtraFilePaths": {
"/etc/tailscale/auth_key": "tailscale.auth_key"
}
}
}
}
This runs two instances:
tailscale up --auth-key=file:/etc/tailscale/auth_key
tailscale serve text:hello