forked from SteamWar/SteamWar
Pot fix for too many open files
This commit is contained in:
@@ -81,4 +81,14 @@ tasks.register<FightServer>("SpaceCraftDev20") {
|
|||||||
template = "SpaceCraft20"
|
template = "SpaceCraft20"
|
||||||
worldName = "arenas/AS_Horizon"
|
worldName = "arenas/AS_Horizon"
|
||||||
config = "SpaceCraftDev20.yml"
|
config = "SpaceCraftDev20.yml"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<FightServer>("QuickGear20") {
|
||||||
|
group = "run"
|
||||||
|
description = "Run a QuickGear 1.20 Fight Server"
|
||||||
|
dependsOn(":SpigotCore:shadowJar")
|
||||||
|
dependsOn(":FightSystem:shadowJar")
|
||||||
|
template = "QuickGear20"
|
||||||
|
worldName = "arenas/WarGearPark"
|
||||||
|
config = "QuickGear20.yml"
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
PREFIX=§eSchematic§8» §7
|
PREFIX=§eSchematic§8»§7
|
||||||
ON=§aon
|
ON=§aon
|
||||||
OFF=§coff
|
OFF=§coff
|
||||||
CHANGE=§7To change
|
CHANGE=§7To change
|
||||||
|
|||||||
@@ -131,7 +131,17 @@ class DevServer extends DefaultTask {
|
|||||||
|
|
||||||
private boolean checkFileOnRemote(String path) {
|
private boolean checkFileOnRemote(String path) {
|
||||||
def process = run("[ -e \"$path\" ] && echo \"true\"")
|
def process = run("[ -e \"$path\" ] && echo \"true\"")
|
||||||
return new BufferedReader(new InputStreamReader(process.inputStream)).lines().count() > 0
|
process.errorStream.close()
|
||||||
|
process.outputStream.close()
|
||||||
|
try (def reader = new BufferedReader(new InputStreamReader(process.inputStream))) {
|
||||||
|
return reader.lines().count() > 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeProcess(Process process) {
|
||||||
|
process.outputStream.close()
|
||||||
|
process.inputStream.close()
|
||||||
|
process.errorStream.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
void setupTemplate(String template) {
|
void setupTemplate(String template) {
|
||||||
@@ -142,6 +152,7 @@ class DevServer extends DefaultTask {
|
|||||||
String serverTemplateName = new BufferedReader(new InputStreamReader(process.inputStream)).lines().collect(Collectors.joining("\n"))
|
String serverTemplateName = new BufferedReader(new InputStreamReader(process.inputStream)).lines().collect(Collectors.joining("\n"))
|
||||||
.trim()
|
.trim()
|
||||||
.substring("Folder: ".length())
|
.substring("Folder: ".length())
|
||||||
|
closeProcess(process);
|
||||||
setupTemplate(serverTemplateName)
|
setupTemplate(serverTemplateName)
|
||||||
run("ln -s $serverTemplateName $template")
|
run("ln -s $serverTemplateName $template")
|
||||||
return
|
return
|
||||||
@@ -149,10 +160,10 @@ class DevServer extends DefaultTask {
|
|||||||
if (!checkFileOnRemote("/servers/$template")) {
|
if (!checkFileOnRemote("/servers/$template")) {
|
||||||
throw new GradleException("Used template ($template) is not in /servers/ directory of the given host $host")
|
throw new GradleException("Used template ($template) is not in /servers/ directory of the given host $host")
|
||||||
}
|
}
|
||||||
run("cp -r /servers/$template $template")
|
closeProcess(run("cp -r /servers/$template $template"))
|
||||||
run("chmod u+w $template")
|
closeProcess(run("chmod u+w $template"))
|
||||||
run("rm -r $template/plugins/*WorldEdit/")
|
closeProcess(run("rm -r $template/plugins/*WorldEdit/"))
|
||||||
run("rm $template/log4j2.xml")
|
closeProcess(run("rm $template/log4j2.xml"))
|
||||||
}
|
}
|
||||||
|
|
||||||
void uploadDependencies() {
|
void uploadDependencies() {
|
||||||
@@ -170,7 +181,7 @@ class DevServer extends DefaultTask {
|
|||||||
|
|
||||||
def archive = archiveTask.archiveFile.get().asFile
|
def archive = archiveTask.archiveFile.get().asFile
|
||||||
|
|
||||||
Process process = new ProcessBuilder("ssh", host, "-T", "sha1sum $base/${archive.name.replace("-all", "")}").start();
|
Process process = new ProcessBuilder("ssh", host, "-T", "sha1sum $base/${archive.name.replace("-all", "")}").start()
|
||||||
byte[] bytes = MessageDigest.getInstance("sha1").digest(archive.bytes)
|
byte[] bytes = MessageDigest.getInstance("sha1").digest(archive.bytes)
|
||||||
StringBuilder sb = new StringBuilder()
|
StringBuilder sb = new StringBuilder()
|
||||||
for (byte b : bytes) {
|
for (byte b : bytes) {
|
||||||
@@ -180,14 +191,20 @@ class DevServer extends DefaultTask {
|
|||||||
process.inputStream.readLines().forEach {
|
process.inputStream.readLines().forEach {
|
||||||
same |= it.startsWith(sb.toString().toLowerCase())
|
same |= it.startsWith(sb.toString().toLowerCase())
|
||||||
}
|
}
|
||||||
|
closeProcess(process);
|
||||||
if (same) {
|
if (same) {
|
||||||
println("Skipping $archive")
|
println("Skipping $archive")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
println("Uploading $archive")
|
println("Uploading $archive")
|
||||||
new ProcessBuilder("ssh", host, "-T", "rm $base/${archive.name.replace("-all", "")}").start().waitFor()
|
process = new ProcessBuilder("ssh", host, "-T", "rm $base/${archive.name.replace("-all", "")}").start()
|
||||||
new ProcessBuilder("scp", archive.absolutePath, "$host:~/$base/${archive.name.replace("-all", "")}").start().waitFor()
|
process.waitFor()
|
||||||
|
closeProcess(process)
|
||||||
|
|
||||||
|
process = new ProcessBuilder("scp", archive.absolutePath, "$host:~/$base/${archive.name.replace("-all", "")}").start();
|
||||||
|
process.waitFor()
|
||||||
|
closeProcess(process)
|
||||||
println("Uploaded $archive")
|
println("Uploaded $archive")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,6 +231,8 @@ class DevServer extends DefaultTask {
|
|||||||
println(processOutput.readLine())
|
println(processOutput.readLine())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
processOutput.close()
|
||||||
|
process.errorStream.close()
|
||||||
}).start()
|
}).start()
|
||||||
|
|
||||||
processInput = new BufferedWriter(new OutputStreamWriter(process.outputStream))
|
processInput = new BufferedWriter(new OutputStreamWriter(process.outputStream))
|
||||||
@@ -226,6 +245,7 @@ class DevServer extends DefaultTask {
|
|||||||
processInput.newLine()
|
processInput.newLine()
|
||||||
processInput.flush()
|
processInput.flush()
|
||||||
}
|
}
|
||||||
|
processInput.close()
|
||||||
}).start()
|
}).start()
|
||||||
|
|
||||||
process.waitFor()
|
process.waitFor()
|
||||||
|
|||||||
Reference in New Issue
Block a user