added go code to start laplace server
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
config.json
|
||||
env/
|
||||
remotegameplay
|
||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/remotegameplay.iml" filepath="$PROJECT_DIR$/.idea/remotegameplay.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/remotegameplay.iml
generated
Normal file
9
.idea/remotegameplay.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="Go" enabled="true" />
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
87
main.go
Normal file
87
main.go
Normal file
@@ -0,0 +1,87 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func main() {
|
||||
err := LaplaceConfig()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
_, err = LaplaceServer(23424)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
// LaplaceConfig Sets up the laplace configuration
|
||||
func LaplaceConfig() error {
|
||||
// Setting up environment variable Laplace
|
||||
curDir := os.Getenv("PWD")
|
||||
os.Setenv("LAPLACE", curDir)
|
||||
|
||||
cmd := exec.Command("./laplace","-setconfig")
|
||||
|
||||
// USE THE FOLLOWING TO DEBUG
|
||||
//cmdReader, err := cmd.StdoutPipe()
|
||||
//if err != nil {
|
||||
// fmt.Fprintln(os.Stderr, "Error creating StdoutPipe for Cmd", err)
|
||||
// return
|
||||
//}
|
||||
//
|
||||
//// the following is used to print output of the command
|
||||
//// as it makes progress...
|
||||
//scanner := bufio.NewScanner(cmdReader)
|
||||
//go func() {
|
||||
// for scanner.Scan() {
|
||||
// fmt.Printf("%s\n", scanner.Text())
|
||||
// //
|
||||
// // TODO:
|
||||
// // send output to server
|
||||
// }
|
||||
//}()
|
||||
//
|
||||
//if err := cmd.Start(); err != nil {
|
||||
// return err
|
||||
//}
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// LaplaceServer Executes the laplace server
|
||||
func LaplaceServer(port int)(*exec.Cmd, error) {
|
||||
cmd := exec.Command("./laplace","-tls","-addr","0.0.0.0:" + fmt.Sprint(port))
|
||||
|
||||
// USE THE FOLLOWING TO DEBUG
|
||||
cmdReader, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Error creating StdoutPipe for Cmd", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// the following is used to print output of the command
|
||||
// as it makes progress...
|
||||
scanner := bufio.NewScanner(cmdReader)
|
||||
go func() {
|
||||
for scanner.Scan() {
|
||||
fmt.Printf("%s\n", scanner.Text())
|
||||
//
|
||||
// TODO:
|
||||
// send output to server
|
||||
}
|
||||
}()
|
||||
|
||||
if err = cmd.Run(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cmd, nil
|
||||
}
|
||||
0
requirements.txt
Normal file
0
requirements.txt
Normal file
Reference in New Issue
Block a user