Documentation ¶
Overview ¶
Example ¶
var cmd *exec.Cmd memd := func(t *TCPTest) { cmd = exec.Command("memcached", "-p", fmt.Sprintf("%d", t.Port())) cmd.SysProcAttr = &syscall.SysProcAttr{ Setpgid: true, } go cmd.Run() for loop := true; loop; { select { case <-t.Done(): cmd.Process.Kill() loop = false } } } server, err := Start2(memd, 30*time.Second) if err != nil { log.Fatalf("Failed to start memcached: %s", err) } log.Printf("memcached started on port %d", server.Port()) defer func() { if cmd != nil && cmd.Process != nil { cmd.Process.Signal(syscall.SIGTERM) } }() // Do what you want... // When you're done, you need to kill the daemon // because, well, it doesn't unless you tell it to! server.Stop() // Wait for the callback goroutine to exit server.Wait()
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TCPTest ¶
type TCPTest struct {
// contains filtered or unexported fields
}
func Start ¶
Start is left for backward compatibility, but you should use Start2(), which allows better management of the lifecycle
Click to show internal directories.
Click to hide internal directories.