Control for Server Process
This commit is contained in:
17
handlers.go
17
handlers.go
@@ -29,7 +29,7 @@ func index(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func update(c *gin.Context) {
|
func update(c *gin.Context) {
|
||||||
cmd := exec.Command("awdaawdawd")
|
cmd := exec.Command("wine", "/root/.wine/drive_c/steamcmd/steamcmd.exe", "+force_install_dir", `C:\VRisingServer`, "+login", "anonymous", "+app_update", "1829350", "+quit")
|
||||||
|
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
cmd.Stdout = &out
|
cmd.Stdout = &out
|
||||||
@@ -125,17 +125,23 @@ func configure(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func doIt() {
|
func doIt() {
|
||||||
server_process := exec.Command("pwd")
|
server_process := exec.Command("xvfb-run", "-a", "wine", "/root/.wine/drive_c/vrisingserver/VRisingServer.exe")
|
||||||
|
|
||||||
var out bytes.Buffer
|
var out bytes.Buffer
|
||||||
server_process.Stdout = &out
|
server_process.Stdout = &out
|
||||||
|
|
||||||
err := server_process.Run()
|
err := server_process.Start()
|
||||||
check(err)
|
check(err)
|
||||||
|
|
||||||
print(out.String())
|
println("Starting...")
|
||||||
<-server_sig
|
<-server_sig
|
||||||
server_process.Process.Signal(os.Kill)
|
|
||||||
|
// Kill Process
|
||||||
|
pkill_process := exec.Command("pkill", "-SIGINT", "Xvfb")
|
||||||
|
pkill_process.Run()
|
||||||
|
server_process.Process.Wait()
|
||||||
|
|
||||||
|
println("Stopped")
|
||||||
}
|
}
|
||||||
|
|
||||||
func startServer(c *gin.Context) {
|
func startServer(c *gin.Context) {
|
||||||
@@ -152,7 +158,6 @@ func stopServer(c *gin.Context) {
|
|||||||
if server_started {
|
if server_started {
|
||||||
server_sig <- 1
|
server_sig <- 1
|
||||||
server_started = false
|
server_started = false
|
||||||
c.String(http.StatusOK, "Process Stopped")
|
|
||||||
} else {
|
} else {
|
||||||
c.String(http.StatusOK, "Already Stopped")
|
c.String(http.StatusOK, "Already Stopped")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user