Running multiple copies of the same module #227
-
Been really enjoying poking around with gokrazy and was considering the use case of running the same module with different arguments concurrently. I know one option could be "fake" modules (local modules that are thin wrappers) A more concrete example: I'm running Tailscale up, but also want to run Tailscale serve for another service at the same time Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I’m glad you’re enjoying gokrazy! The way I currently deal with running multiple instances is by setting package main
import (
"log"
"os"
"os/exec"
"syscall"
)
func main() {
bridge := exec.Command("/user/robustirc-bridge", "-network=robustirc.net")
bridge.Stdout = os.Stdout
bridge.Stderr = os.Stderr
bridge.Env = []string{} // clear environment
bridge.SysProcAttr = &syscall.SysProcAttr{
Credential: &syscall.Credential{
Uid: 65534, // nobody
Gid: 65534, // nogroup
},
}
if err := bridge.Run(); err != nil {
log.Fatal(err)
}
} Note that for tailscale in particular, both |
Beta Was this translation helpful? Give feedback.
I’m glad you’re enjoying gokrazy!
The way I currently deal with running multiple instances is by setting
"DontStart": true
on the module in question (e.g. the RobustIRC bridge), and then having one or more small wrapper programs that start the desired instances: