Exemplo n.º 1
0
func main() {

	ctx := gozd.Context{
		Hash:    "https_example",
		Logfile: os.TempDir() + "https_daemon.log",
		Directives: map[string]gozd.Server{
			"tcp_sock": gozd.Server{
				Network: "unix",
				Address: os.TempDir() + "mixed_tcp.sock",
			},
			"tcp_port": gozd.Server{
				Network: "tcp",
				Address: "127.0.0.1:9000",
			},
			"fcgi": gozd.Server{
				Network: "unix",
				Address: os.TempDir() + "mixed_fcgi.sock",
			},
			"https": gozd.Server{
				Network: "tcp",
				Address: "127.0.0.1:8443",
			},
			"http": gozd.Server{
				Network: "tcp",
				Address: "127.0.0.1:8080",
			},
		},
	}

	cl := make(chan net.Listener, 1)
	go handleListners(cl)
	sig, err := gozd.Daemonize(ctx, cl) // returns channel that connects with daemon
	if err != nil {
		log.Println("error: ", err)
		return
	}

	// other initializations or config setting

	for s := range sig {
		switch s {
		case syscall.SIGHUP, syscall.SIGUSR2:
			// do some custom jobs while reload/hotupdate

		case syscall.SIGTERM:
			// do some clean up and exit
			return
		}
	}
}
Exemplo n.º 2
0
func main() {
	// parse arguments
	flag.Parse()

	if *optHelp {
		usage()
		return
	}

	// parse conf file
	file, err := ioutil.ReadFile(*optConfPath)
	if err != nil {
		log.Println("error: ", err)
		return
	}

	var ctx gozd.Context
	err = json.Unmarshal(file, &ctx)
	if err != nil {
		log.Println("error: ", err)
		return
	}

	ctx.Command = *optCommand
	ctx.Hash = *optConfPath
	ctx.Pidfile = *optPidPath

	cl := make(chan net.Listener, 1)
	go handleListners(cl)
	sig, err := gozd.Daemonize(ctx, cl) // returns channel that connects with daemon
	if err != nil {
		log.Println("error: ", err)
		return
	}

	// other initializations or config setting

	for s := range sig {
		switch s {
		case syscall.SIGHUP, syscall.SIGUSR2:
			// do some custom jobs while reload/hotupdate

		case syscall.SIGTERM:
			// do some clean up and exit
			return
		}
	}
}
Exemplo n.º 3
0
func main() {

	// parse arguments
	flag.Parse()

	if *optHelp || len(*optServerID) <= 0 || len(*optAccept) <= 0 || len(*optConnect) <= 0 {
		usage()
		return
	}

	log.Println(os.TempDir())
	ctx := gozd.Context{
		Hash:    *optServerID,
		Command: "start",
		Maxfds:  syscall.Rlimit{Cur: 32677, Max: 32677},
		User:    "******",
		Group:   "nobody",
		Logfile: "ftunnel.log",
		Directives: map[string]gozd.Server{
			"client": gozd.Server{
				Network: "tcp",
				Address: *optAccept,
			},
		},
	}

	cl := make(chan net.Listener, 1)
	go ftunnel.HandleListners(cl, *optConnect)
	sig, err := gozd.Daemonize(ctx, cl) // returns channel that connects with daemon
	if err != nil {
		log.Println("error: ", err)
		return
	}

	// other initializations or config setting
	for s := range sig {
		switch s {
		case syscall.SIGHUP, syscall.SIGUSR2:
			// do some custom jobs while reload/hotupdate

		case syscall.SIGTERM:
			// do some clean up and exit
			return
		}
	}
}
Exemplo n.º 4
0
func main() {
	log.Println(os.TempDir())
	ctx := gozd.Context{
		Hash:    "tcp_example",
		Command: "start",
		Maxfds:  syscall.Rlimit{Cur: 32677, Max: 32677},
		User:    "******",
		Group:   "www",
		Logfile: path.Join(os.TempDir(), "tcp_daemon.log"),
		Directives: map[string]gozd.Server{
			"sock": gozd.Server{
				Network: "unix",
				Address: path.Join(os.TempDir(), "tcp_daemon.sock"),
			},
			"port1": gozd.Server{
				Network: "tcp",
				Address: "127.0.0.1:2133",
			},
			"port2": gozd.Server{
				Network: "tcp",
				Address: "127.0.0.1:2233",
			},
		},
	}

	cl := make(chan net.Listener, 1)
	go handleListners(cl)
	sig, err := gozd.Daemonize(ctx, cl) // returns channel that connects with daemon
	if err != nil {
		log.Println("error: ", err)
		return
	}

	// other initializations or config setting

	for s := range sig {
		switch s {
		case syscall.SIGHUP, syscall.SIGUSR2:
			// do some custom jobs while reload/hotupdate

		case syscall.SIGTERM:
			// do some clean up and exit
			return
		}
	}
}
Exemplo n.º 5
0
func Start() {
	server_address := goCfgMgr.Get("basic", "Host").(string) + ":" +
		goCfgMgr.Get("basic", "Port").(string)

	ctx := gozd.Context{
		Hash:    "pin_dump_test",
		Logfile: os.TempDir() + "/pin_dump_test.log",
		Directives: map[string]gozd.Server{
			"sock": gozd.Server{
				Network: "unix",
				Address: os.TempDir() + "/pin_dump_test.sock",
			},
			"port1": gozd.Server{
				Network: "tcp",
				Address: server_address,
			},
		},
	}
	dumpProcessChan = make(chan int, 15)
	cl := make(chan net.Listener, 1)
	go handleListners(cl)
	sig, err := gozd.Daemonize(ctx, cl) // returns channel that connects with daemon
	if err != nil {
		log.Println("error: ", err)
		return
	}

	// other initializations or config setting

	for s := range sig {
		switch s {
		case syscall.SIGHUP, syscall.SIGUSR2:
			// do some custom jobs while reload/hotupdate

		case syscall.SIGTERM:
			// do some clean up and exit
			return
		}
	}

	dbinfo.Init()

	go dbinfo.Check_Sql_Connect()
	go debug.CheckMemStats()
}