use bubblewrap
This commit is contained in:
Executable
+25
@@ -0,0 +1,25 @@
|
|||||||
|
#/bin/bash
|
||||||
|
|
||||||
|
(exec bwrap\
|
||||||
|
--ro-bind ../../lean4game /lean4game \
|
||||||
|
--ro-bind ../../$1 /game \
|
||||||
|
--ro-bind ~/.elan /elan \
|
||||||
|
--ro-bind /usr /usr \
|
||||||
|
--dev /dev \
|
||||||
|
--proc /proc \
|
||||||
|
--symlink usr/lib /lib\
|
||||||
|
--symlink usr/lib64 /lib64\
|
||||||
|
--symlink usr/bin /bin\
|
||||||
|
--symlink usr/sbin /sbin\
|
||||||
|
--clearenv \
|
||||||
|
--setenv PATH "/elan/bin:/bin" \
|
||||||
|
--setenv ELAN_HOME "/elan" \
|
||||||
|
--unshare-user \
|
||||||
|
--unshare-pid \
|
||||||
|
--unshare-net \
|
||||||
|
--unshare-uts \
|
||||||
|
--unshare-cgroup \
|
||||||
|
--die-with-parent \
|
||||||
|
--chdir "/lean4game/server/build/bin/" \
|
||||||
|
./gameserver --server /game
|
||||||
|
)
|
||||||
+15
-10
@@ -19,18 +19,18 @@ const games = {
|
|||||||
"g/hhu-adam/robo": {
|
"g/hhu-adam/robo": {
|
||||||
// module: "Game", // The lean module's name. Defaults to "Game"
|
// module: "Game", // The lean module's name. Defaults to "Game"
|
||||||
// name: "Adam", // For the `Game "Adam"` tag in the games. Defaults to "MyGame"
|
// name: "Adam", // For the `Game "Adam"` tag in the games. Defaults to "MyGame"
|
||||||
dir: "../../../../Robo",
|
dir: "Robo",
|
||||||
queueLength: 5
|
queueLength: 5
|
||||||
},
|
},
|
||||||
"g/hhu-adam/nng4": {
|
"g/hhu-adam/nng4": {
|
||||||
// module: "Game",
|
// module: "Game",
|
||||||
// name: "NNG",
|
// name: "NNG",
|
||||||
dir: "../../../../NNG4",
|
dir: "NNG4",
|
||||||
queueLength: 5
|
queueLength: 5
|
||||||
},
|
},
|
||||||
"g/local/game": {
|
"g/local/game": {
|
||||||
dir: "../../../../game",
|
dir: "game",
|
||||||
queueLength: 5
|
queueLength: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,19 +62,24 @@ const isDevelopment = environment === 'development'
|
|||||||
const queue = {}
|
const queue = {}
|
||||||
|
|
||||||
function startServerProcess(tag) {
|
function startServerProcess(tag) {
|
||||||
|
if (! games[tag]?.dir) {
|
||||||
|
console.error(`Unknown game: ${tag}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let serverProcess
|
let serverProcess
|
||||||
if (isDevelopment && games[tag]?.dir) {
|
if (isDevelopment) {
|
||||||
let args = ["--server", games[tag].dir]
|
let args = ["--server", path.join("../../../../", games[tag].dir)]
|
||||||
if (games[tag].module) {
|
if (games[tag].module) {
|
||||||
args.push(games[tag].module)
|
args.push(games[tag].module)
|
||||||
if (games[tag].name) { args.push(games[tag].name) }
|
if (games[tag].name) { args.push(games[tag].name) }
|
||||||
}
|
}
|
||||||
serverProcess = cp.spawn("./gameserver", args,
|
serverProcess = cp.spawn("./gameserver", args,
|
||||||
{ cwd: "./build/bin/" })
|
{ cwd: path.join(__dirname, "./build/bin/") })
|
||||||
} else {
|
} else {
|
||||||
serverProcess = cp.spawn("docker",
|
serverProcess = cp.spawn("./bubblewrap.sh",
|
||||||
["run", "--runtime=runsc", "--network=none", "--rm", "-i", `${tag}`],
|
[games[tag].dir],
|
||||||
{ cwd: "." })
|
{ cwd: __dirname })
|
||||||
}
|
}
|
||||||
serverProcess.on('error', error =>
|
serverProcess.on('error', error =>
|
||||||
console.error(`Launching Lean Server failed: ${error}`)
|
console.error(`Launching Lean Server failed: ${error}`)
|
||||||
|
|||||||
Reference in New Issue
Block a user