You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"os/exec"
|
|
|
|
"os/signal"
|
|
|
|
|
|
|
|
"github.com/zggsong/FileSync/config"
|
|
|
|
"github.com/zggsong/FileSync/server"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
|
|
go server.Run()
|
|
|
|
cmd := startBrowser()
|
|
|
|
chSingal := listen2Interrupt()
|
|
|
|
select {
|
|
|
|
case <-chSingal:
|
|
|
|
cmd.Process.Kill()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func startBrowser() *exec.Cmd {
|
|
|
|
chromePath := "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
|
|
|
|
cmd := exec.Command(chromePath, "--app=http://127.0.0.1:"+config.GetPort()+"/static/index.html")
|
|
|
|
cmd.Start()
|
|
|
|
return cmd
|
|
|
|
}
|
|
|
|
|
|
|
|
//监听中断信号
|
|
|
|
func listen2Interrupt() chan os.Signal {
|
|
|
|
chSignal := make(chan os.Signal, 1)
|
|
|
|
signal.Notify(chSignal, os.Interrupt)
|
|
|
|
return chSignal
|
|
|
|
}
|