예제 #1
0
func modifyNginx() {
	if len(os.Args) < 3 {
		log.Info("usage:params isn't invalid")
		os.Exit(1)
	}
	nginxPath := os.Args[2]
	nginxPort := "80"
	if len(os.Args) > 3 {
		nginxPort = os.Args[3]
	}
	hostprocess := &imgsvr.HostProcessor{
		Port:        0,
		ThreadCount: 0,
		NginxPath:   nginxPath,
		NginxPort:   nginxPort,
	}
	hostprocess.ModifyNginxconf()
}
예제 #2
0
func s() {
	if len(os.Args) < 3 {
		log.Info("usage:params isn't invalid")
		os.Exit(1)
	}
	portstr := os.Args[2]
	var hostport string = ""
	if len(os.Args) > 3 {
		_, err := strconv.Atoi(os.Args[3])
		if err == nil {
			hostport = os.Args[3]
		}
	}
	subprocess := &imgsvr.SubProcessor{
		Port:     portstr,
		HostPort: hostport,
	}
	subprocess.Run()
}
예제 #3
0
func reload() {
	if len(os.Args) < 3 {
		log.Info("usage:params isn't invalid")
		os.Exit(1)
	}
	portstr := os.Args[2]
	port, err := strconv.Atoi(portstr)
	if err != nil {
		log.Error(err.Error())
		os.Exit(1)
	}
	hostprocess := &imgsvr.HostProcessor{
		Port:        port,
		ThreadCount: 0,
		NginxPath:   "",
		NginxPort:   "",
	}
	hostprocess.ReloadConf()
}
예제 #4
0
func h() {
	if len(os.Args) < 3 {
		log.Info("usage:params isn't invalid")
		os.Exit(1)
	}
	portstr := os.Args[2]
	port, err := strconv.Atoi(portstr)
	if err != nil {
		log.Error(err)
		os.Exit(1)
	}
	threadcount, nginxpath, nginxport := getArgs()
	hostprocess := &imgsvr.HostProcessor{
		Port:        port,
		ThreadCount: threadcount,
		NginxPath:   nginxpath,
		NginxPort:   nginxport,
	}
	hostprocess.Run()
}
예제 #5
0
func main() {
	runtime.GOMAXPROCS(1)
	if len(os.Args) < 2 {
		log.Info("usage:params isn't invalid")
		os.Exit(1)
	}
	cmd := os.Args[1]
	if cmd == "-stop" {
		stop()
	}
	if cmd == "-nginx" {
		modifyNginx()
	}
	if cmd == "-h" {
		h()
	}
	if cmd == "-s" {
		s()
	}
	if cmd == "-reload" {
		reload()
	}
}