MCPcopy
hub / github.com/tailscale/tailscale / ExampleServer_multipleInstances

Function ExampleServer_multipleInstances

tsnet/example_tsnet_test.go:69–92  ·  view source on GitHub ↗

ExampleServer_multipleInstances shows you how to configure multiple instances of tsnet per program. This allows you to have multiple Tailscale nodes in the same process/container.

()

Source from the content-addressed store, hash-verified

67// of tsnet per program. This allows you to have multiple Tailscale nodes in the
68// same process/container.
69func ExampleServer_multipleInstances() {
70 baseDir := "/data"
71 var servers []*tsnet.Server
72 for _, hostname := range []string{"ichika", "nino", "miku", "yotsuba", "itsuki"} {
73 os.MkdirAll(filepath.Join(baseDir, hostname), 0700)
74 srv := &tsnet.Server{
75 Hostname: hostname,
76 AuthKey: os.Getenv("TS_AUTHKEY"),
77 Ephemeral: true,
78 Dir: filepath.Join(baseDir, hostname),
79 }
80 if err := srv.Start(); err != nil {
81 log.Fatalf("can't start tsnet server: %v", err)
82 }
83 servers = append(servers, srv)
84 }
85
86 // When you're done, close the instances
87 defer func() {
88 for _, srv := range servers {
89 srv.Close()
90 }
91 }()
92}
93
94// ExampleServer_ignoreLogsSometimes shows you how to ignore all of the log messages
95// written by a tsnet instance, but allows you to opt-into them if a command-line

Callers

nothing calls this directly

Calls 3

StartMethod · 0.95
CloseMethod · 0.95
FatalfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…