Exemple #1
0
func main() {

	if len(os.Args) < 2 {
		log.ErrorNoLine(`
	Please Input Server Name And Params:
	Absolute path
		`)
		return
	}

	filePath, err := filepath.Abs(os.Args[1])
	if err != nil {
		log.Error(err)
	}

	server := Exec(filePath, os.Args[2:]...)
	err = server.Start()
	if err != nil {
		filePath = os.Args[1]
		server = Exec(filePath, os.Args[2:]...)
		err2 := server.Start()
		if err2 != nil {
			log.Error(err2)
			return
		}
		return
	}

	log.Info("Start Daemon Server Ok!\n", os.Args[1])

	return
}
Exemple #2
0
func SendSignal(pid int, _signal os.Signal) {
	process, err := os.FindProcess(pid)
	if err != nil {
		log.Error(err)
		return
	}

	process.Signal(_signal)
}
Exemple #3
0
func GetApp(write io.Writer, param string) {
	cmd := exec.Command("/bin/bash", "-c", `ps aux | awk '`+param+` {print $1" "$2" "$11}'`)

	cmd.Stdout = write
	err := cmd.Run()
	if err != nil {
		log.Error(err)
		return
	}
}
Exemple #4
0
func StartApp(root string, app string) {
	cmd := exec.Command("run", root+app)
	log.Info("Start : ", root+app)

	file, err := os.OpenFile(root+app+".log", os.O_CREATE|os.O_RDWR|os.O_APPEND, 0660)
	if err != nil {
		log.Error(err)
		return
	}

	cmd.Stdout = file
	cmd.Stdin = os.Stdin
	cmd.Stderr = file

	err = cmd.Run()
	if err != nil {
		log.Error(err)
		return
	}

	return
}
Exemple #5
0
func main() {

	if len(os.Args) < 2 {
		log.ErrorNoLine(`
	Please Input Server Name And Params:
	Absolute path
		`)
		return
	}

	filePath, err := filepath.Abs(os.Args[1])
	if err != nil {
		log.Error(err)
		return
	}

	server := exec.Command(filePath, os.Args[2:]...)
	server.Stdout = os.Stdout
	server.Stderr = os.Stderr
	server.Stdin = os.Stdin

	var path string

	if GetRelative(path) >= 0 {
		path = GetPath(os.Args[1])
		server.Dir = path
	}

	err = server.Start()
	if err != nil {
		log.Error(err)
		return
	}

	log.Info("Start Daemon Server Ok!\n", os.Args[1])

	return
}
Exemple #6
0
func main() {
	if len(os.Args) < 2 {
		log.Info("Please input process id :")
		return
	}

	pid, err := strconv.Atoi(os.Args[1])
	if err != nil {
		log.Error(err)
		return
	}

	watcher.ShutDown(pid)
}