コード例 #1
0
ファイル: main.go プロジェクト: CyCoreSystems/ccproxy
func main() {
	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	// Make sure /tmp exists
	os.Mkdir("/tmp", 0777)

	// Start the services manager
	err := services.Go(ctx)
	if err != nil {
		fmt.Println("Failed to start service manager:", err.Error())
		return
	}

	// Start the dns manager
	err = dns.Go(ctx)
	if err != nil {
		fmt.Println("Failed to start dns manager:", err.Error())
		return
	}

	// Wait for a stop signal
	// Wait for OS to signal stop
	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt, os.Kill)

	// Block until a signal is received.
	select {
	case <-c:
		fmt.Println("Got signal; stopping")
	case <-ctx.Done():
	}

	return
}
コード例 #2
0
ファイル: main.go プロジェクト: mehulsbhatt/ccproxy
func main() {
	stopChan := make(chan struct{})

	// Start the services manager
	err := services.Go(stopChan)
	if err != nil {
		fmt.Println("Failed to start service manager:", err.Error())
		return
	}

	// Start the dns manager
	err = dns.Go()
	if err != nil {
		fmt.Println("Failed to start dns manager:", err.Error())
		return
	}

	// Wait for a stop signal
	waitStop(stopChan)
	return
}