tmp2
This commit is contained in:
58
MultiServer/pom.xml
Normal file
58
MultiServer/pom.xml
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
|
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<name>Multi Server</name>
|
||||||
|
|
||||||
|
<artifactId>multiserver</artifactId>
|
||||||
|
<version>0.1</version>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>asys</groupId>
|
||||||
|
<artifactId>asys</artifactId>
|
||||||
|
<version>0.5</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>asys</groupId>
|
||||||
|
<artifactId>core</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.groupId}.${project.artifactId}-${project.version}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-Name>ASys: ${project.name}</Bundle-Name>
|
||||||
|
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
|
||||||
|
<Bundle-Activator>asys.multiserver.Activator</Bundle-Activator>
|
||||||
|
<Import-Package>asys.core.api, *</Import-Package>
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifestEntries>
|
||||||
|
<Service-Provide>asys.core.api.IServerManager</Service-Provide>
|
||||||
|
</manifestEntries>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
69
SingleServer/Protocol/pom.xml
Normal file
69
SingleServer/Protocol/pom.xml
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
|
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<name>ASys Bridge Protocol</name>
|
||||||
|
<url>http://dmitriymx.ru/</url>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<name>DmitriyMX</name>
|
||||||
|
<email>mail@dmiriymx.ru</email>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<groupId>asys</groupId>
|
||||||
|
<artifactId>bridge-protocol</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<version>0.1</version>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty-all</artifactId>
|
||||||
|
<version>4.0.23.Final</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}-${project.version}</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>${project.basedir}/src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**</include>
|
||||||
|
</includes>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.5.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.15</version>
|
||||||
|
<configuration>
|
||||||
|
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
90
SingleServer/bukkit-plugin/pom.xml
Normal file
90
SingleServer/bukkit-plugin/pom.xml
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||||
|
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<name>ASys Bridge</name>
|
||||||
|
<url>http://dmitriymx.ru/</url>
|
||||||
|
|
||||||
|
<developers>
|
||||||
|
<developer>
|
||||||
|
<name>DmitriyMX</name>
|
||||||
|
<email>mail@dmiriymx.ru</email>
|
||||||
|
</developer>
|
||||||
|
</developers>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<bukkit.version>1.8.8-R0.1-SNAPSHOT</bukkit.version>
|
||||||
|
<bukkit.mainclass>asys.bridge.ASysBukkitBridge</bukkit.mainclass>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<groupId>asys</groupId>
|
||||||
|
<artifactId>bridge</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<version>1.0</version>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigot</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
<version>${bukkit.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.googlecode.json-simple</groupId>
|
||||||
|
<artifactId>json-simple</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty-all</artifactId>
|
||||||
|
<version>4.0.23.Final</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>asysbridge-${project.version}</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>${project.basedir}/src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>**</include>
|
||||||
|
</includes>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.5.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
<encoding>${project.build.sourceEncoding}</encoding>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.15</version>
|
||||||
|
<configuration>
|
||||||
|
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <mail@dmitriymx.ru>
|
||||||
|
* 2016-08-08
|
||||||
|
*/
|
||||||
|
package asys.bridge;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Инфо:
|
||||||
|
* - ID сервера
|
||||||
|
* - кол-во игроков
|
||||||
|
* - максимальный онлайн
|
||||||
|
* - политика присоединения
|
||||||
|
*/
|
||||||
|
public class ASysBukkitBridge extends JavaPlugin {
|
||||||
|
private String idServer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
idServer = System.getProperty("asys.server.name");
|
||||||
|
if (idServer == null || idServer.trim().isEmpty()) {
|
||||||
|
getLogger().severe("Don't get property \"asys.server.name\"");
|
||||||
|
getLogger().severe("Server shutdown!");
|
||||||
|
getServer().shutdown();
|
||||||
|
} else {
|
||||||
|
getLogger().info(String.format("Server ID: %s", idServer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
getLogger().info("Bye");
|
||||||
|
}
|
||||||
|
}
|
||||||
5
SingleServer/bukkit-plugin/src/main/resources/plugin.yml
Normal file
5
SingleServer/bukkit-plugin/src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
name: ASysBridge
|
||||||
|
main: ${bukkit.mainclass}
|
||||||
|
version: ${project.version}
|
||||||
|
description: 'Plugin-connector for ASys'
|
||||||
|
author: DmitriyMX
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<name>Single Server</name>
|
<name>Single Server</name>
|
||||||
|
|
||||||
<artifactId>singleserver</artifactId>
|
<artifactId>singleserver</artifactId>
|
||||||
<version>0.16</version>
|
<version>0.26</version>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>asys</groupId>
|
<groupId>asys</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>0.18</version>
|
<version>RELEASE</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
15
SingleServer/src/main/java/asys/singleserver/Command.java
Normal file
15
SingleServer/src/main/java/asys/singleserver/Command.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <mail@dmitriymx.ru>
|
||||||
|
* 2016-08-14
|
||||||
|
*/
|
||||||
|
package asys.singleserver;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(value = ElementType.METHOD)
|
||||||
|
@Retention(value = RetentionPolicy.RUNTIME)
|
||||||
|
public @interface Command {
|
||||||
|
}
|
||||||
@@ -4,29 +4,84 @@
|
|||||||
*/
|
*/
|
||||||
package asys.singleserver;
|
package asys.singleserver;
|
||||||
|
|
||||||
|
import asys.core.api.IMinecraftServer;
|
||||||
import asys.core.api.IServerManager;
|
import asys.core.api.IServerManager;
|
||||||
import org.apache.felix.service.command.Descriptor;
|
import org.apache.felix.service.command.Descriptor;
|
||||||
|
import org.apache.felix.service.command.Parameter;
|
||||||
|
|
||||||
import java.util.Dictionary;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Hashtable;
|
import java.util.*;
|
||||||
|
|
||||||
public class Commands {
|
public class Commands {
|
||||||
private IServerManager serverManager;
|
private IServerManager serverManager;
|
||||||
|
|
||||||
public static Dictionary<String, Object> getDictionary() {
|
public static Dictionary<String, Object> getProps(String group) {
|
||||||
Hashtable<String, Object> dictionary = new Hashtable<>();
|
List<String> listCommand = new ArrayList<>();
|
||||||
dictionary.put("osgi.command.scope", "asys.singleserver");
|
|
||||||
dictionary.put("osgi.command.function", new String[] { "startserver" });
|
try {
|
||||||
return dictionary;
|
Class clazz = Class.forName(Commands.class.getName());
|
||||||
|
Method[] methods = clazz.getMethods();
|
||||||
|
for(Method method : methods) {
|
||||||
|
if (method.isAnnotationPresent(Command.class)) {
|
||||||
|
listCommand.add(method.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
Hashtable<String, Object> props = new Hashtable<>();
|
||||||
|
if (listCommand.size() > 0) {
|
||||||
|
props.put("osgi.command.scope", group);
|
||||||
|
props.put("osgi.command.function", listCommand.toArray(new String[listCommand.size()]));
|
||||||
|
}
|
||||||
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Commands(IServerManager serverManager) {
|
public Commands(IServerManager serverManager) {
|
||||||
this.serverManager = serverManager;
|
this.serverManager = serverManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
@Descriptor("Server start")
|
@Descriptor("Server start")
|
||||||
public void startserver() {
|
public void start() {
|
||||||
serverManager.getServer(null).start();
|
serverManager.getServer(null).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@Descriptor("Server stop")
|
||||||
|
public void stop() {
|
||||||
|
serverManager.getServer(null).stop();
|
||||||
|
serverManager.removeServer(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@Descriptor("Server force stop")
|
||||||
|
public void forceStop() {
|
||||||
|
serverManager.getServer(null).forceStop();
|
||||||
|
serverManager.removeServer(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@Descriptor("Server restart")
|
||||||
|
public void restart() {
|
||||||
|
IMinecraftServer server = serverManager.getServer(null);
|
||||||
|
server.stop();
|
||||||
|
server.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@Descriptor("Server is alive?")
|
||||||
|
public void isAlive() {
|
||||||
|
boolean alive = serverManager.getServer(null).isAlive();
|
||||||
|
System.out.println(String.format("Server is alive: %s", alive));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command
|
||||||
|
@Descriptor("Send server command")
|
||||||
|
public void cmd(String... command) {
|
||||||
|
StringJoiner sj = new StringJoiner(" ");
|
||||||
|
Arrays.asList(command).forEach(sj::add);
|
||||||
|
serverManager.getServer(null).sendCommand(sj.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,25 +11,17 @@ import java.nio.file.Path;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
public class MinecraftWinServer implements IMinecraftServer {
|
public class MinecraftProcessServer implements IMinecraftServer {
|
||||||
private ProcessBuilder processBuilder;
|
private ProcessBuilder processBuilder;
|
||||||
|
private Process process;
|
||||||
|
private String name;
|
||||||
|
|
||||||
/** запуск через скрипт */
|
public MinecraftProcessServer(String name, Path directory, Path mainJar, String jvmArgs, String params) {
|
||||||
public MinecraftWinServer(Path directory, Path script) {
|
|
||||||
processBuilder = new ProcessBuilder();
|
|
||||||
processBuilder.directory(directory.toFile());
|
|
||||||
processBuilder.command("cmd.exe", "/C", "start", script.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** запуск через asys */
|
|
||||||
public MinecraftWinServer(Path directory, Path mainJar, String jvmArgs, String params) {
|
|
||||||
processBuilder = new ProcessBuilder();
|
processBuilder = new ProcessBuilder();
|
||||||
processBuilder.directory(directory.toFile());
|
processBuilder.directory(directory.toFile());
|
||||||
List<String> commandLine = new Vector<>();
|
List<String> commandLine = new Vector<>();
|
||||||
commandLine.add("cmd.exe");
|
|
||||||
commandLine.add("/C");
|
|
||||||
commandLine.add("start");
|
|
||||||
commandLine.add("java");
|
commandLine.add("java");
|
||||||
|
commandLine.add("-Dasys.server.name=\""+name+"\"");
|
||||||
if (jvmArgs != null && !jvmArgs.trim().isEmpty()) {
|
if (jvmArgs != null && !jvmArgs.trim().isEmpty()) {
|
||||||
commandLine.add(jvmArgs);
|
commandLine.add(jvmArgs);
|
||||||
}
|
}
|
||||||
@@ -39,12 +31,18 @@ public class MinecraftWinServer implements IMinecraftServer {
|
|||||||
commandLine.add(params);
|
commandLine.add(params);
|
||||||
}
|
}
|
||||||
processBuilder.command(commandLine);
|
processBuilder.command(commandLine);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
try {
|
try {
|
||||||
processBuilder.start();
|
process = processBuilder.start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -57,16 +55,23 @@ public class MinecraftWinServer implements IMinecraftServer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void forceStop() {
|
public void forceStop() {
|
||||||
//TODO need code
|
process.destroy();
|
||||||
}
|
process = null;
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isAlive() {
|
|
||||||
return false; //TODO need code
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendCommand(String command) {
|
public void sendCommand(String command) {
|
||||||
//TODO need code
|
try {
|
||||||
|
process.getOutputStream().write(command.getBytes());
|
||||||
|
process.getOutputStream().write("\n".getBytes());
|
||||||
|
process.getOutputStream().flush();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAlive() {
|
||||||
|
return process.isAlive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <mail@dmitriymx.ru>
|
||||||
|
* 2016-08-11
|
||||||
|
*/
|
||||||
|
package asys.singleserver;
|
||||||
|
|
||||||
|
import asys.core.api.IMinecraftServer;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
public class MinecraftScreenServer implements IMinecraftServer {
|
||||||
|
private ProcessBuilder startPB;
|
||||||
|
private String name;
|
||||||
|
private String serverPID;
|
||||||
|
|
||||||
|
public MinecraftScreenServer(String name, Path directory, Path mainJar, String jvmArgs, String params) {
|
||||||
|
startPB = new ProcessBuilder();
|
||||||
|
startPB.directory(directory.toFile());
|
||||||
|
List<String> commandLine = new Vector<>(Arrays.asList("screen", "-dmS", name, "java", "-Dasys.server.name=\""+name+"\""));
|
||||||
|
if (jvmArgs != null && !jvmArgs.trim().isEmpty()) {
|
||||||
|
commandLine.add(jvmArgs);
|
||||||
|
}
|
||||||
|
commandLine.add("-jar");
|
||||||
|
commandLine.add(mainJar.toString());
|
||||||
|
if (params != null && !params.trim().isEmpty()) {
|
||||||
|
commandLine.add(params);
|
||||||
|
}
|
||||||
|
startPB.command(commandLine);
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start() {
|
||||||
|
try {
|
||||||
|
startPB.start();
|
||||||
|
|
||||||
|
Thread.sleep(500);
|
||||||
|
|
||||||
|
Process process = Runtime.getRuntime().exec("bash -c \"screen -ls | sed 's/\\t//g' | grep '\\."+name+"(' | cut -f1 -d.\"");
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
String out = br.readLine();
|
||||||
|
br.close();
|
||||||
|
|
||||||
|
process = Runtime.getRuntime().exec("pgrep -P " + out);
|
||||||
|
br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
serverPID = br.readLine();
|
||||||
|
br.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop() {
|
||||||
|
sendCommand("stop");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void forceStop() {
|
||||||
|
ProcessBuilder sendCmdPB = new ProcessBuilder();
|
||||||
|
sendCmdPB.command("screen", "-S", name, "-X", "quit");
|
||||||
|
try {
|
||||||
|
sendCmdPB.start();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendCommand(String command) {
|
||||||
|
ProcessBuilder sendCmdPB = new ProcessBuilder();
|
||||||
|
sendCmdPB.command("screen", "-S", name, "-p", "0", "-X", "stuff", command+"\\r");
|
||||||
|
try {
|
||||||
|
sendCmdPB.start();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAlive() {
|
||||||
|
try {
|
||||||
|
Process process = Runtime.getRuntime().exec("ps -p " + serverPID);
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||||
|
br.readLine();
|
||||||
|
String line = br.readLine();
|
||||||
|
br.close();
|
||||||
|
return (line != null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@ import asys.core.api.ICore;
|
|||||||
import asys.core.api.IMinecraftServer;
|
import asys.core.api.IMinecraftServer;
|
||||||
import asys.core.api.IServerManager;
|
import asys.core.api.IServerManager;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
@@ -16,36 +18,37 @@ import java.util.Properties;
|
|||||||
|
|
||||||
public class SingleServer implements IServerManager {
|
public class SingleServer implements IServerManager {
|
||||||
private IMinecraftServer mcServer;
|
private IMinecraftServer mcServer;
|
||||||
private BundleContext bundleContext;
|
private Logger logger = LoggerFactory.getLogger(SingleServer.class.getName());
|
||||||
|
private Properties configuration;
|
||||||
|
|
||||||
public SingleServer(BundleContext bundleContext) {
|
public SingleServer(Properties configuration) {
|
||||||
this.bundleContext = bundleContext;
|
this.configuration = configuration;
|
||||||
|
|
||||||
Path serverPath = Paths.get(getProperty("asys.singleserver.server.path"));
|
prepareMcServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepareMcServer() {
|
||||||
|
Path serverPath = Paths.get(configuration.getProperty("asys.singleserver.server.path"));
|
||||||
if (Files.notExists(serverPath)) {
|
if (Files.notExists(serverPath)) {
|
||||||
throw new RuntimeException(String.format("Server path \"%s\" not found", serverPath.toString()));
|
throw new RuntimeException(String.format("Server path \"%s\" not found", serverPath.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getProperty("asys.singleserver.runscript.use", "false").equalsIgnoreCase("true")) {
|
Path mainJar = serverPath.resolve(configuration.getProperty("asys.singleserver.server.mainjar"));
|
||||||
Path scriptFile = Paths.get(getProperty("asys.singleserver.runscript.file"));
|
if (Files.notExists(mainJar)) {
|
||||||
if (Files.notExists(scriptFile)) {
|
throw new RuntimeException(String.format("Main jar \"%s\" not found", mainJar.toString()));
|
||||||
throw new RuntimeException(String.format("Runscript \"%s\" not found", scriptFile.toString()));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!Files.isExecutable(scriptFile)) {
|
String typeServerImplement = configuration.getProperty("asys.singleserver.typeImplement", "process");
|
||||||
throw new RuntimeException(String.format("Runscript \"%s\" is not executable", scriptFile.toString()));
|
if (typeServerImplement.equalsIgnoreCase("screen")) {
|
||||||
}
|
logger.debug("Used server implement: screen");
|
||||||
|
mcServer = new MinecraftScreenServer("mcserver", serverPath, mainJar,
|
||||||
mcServer = new MinecraftWinServer(serverPath, scriptFile);
|
configuration.getProperty("asys.singleserver.server.jvm.args", null),
|
||||||
|
configuration.getProperty("asys.singleserver.server.params", null));
|
||||||
} else {
|
} else {
|
||||||
Path mainJar = serverPath.resolve(getProperty("asys.singleserver.server.mainjar"));
|
logger.debug("Used server implement: process");
|
||||||
if (Files.notExists(mainJar)) {
|
mcServer = new MinecraftProcessServer("mcserver", serverPath, mainJar,
|
||||||
throw new RuntimeException(String.format("Main jar \"%s\" not found", mainJar.toString()));
|
configuration.getProperty("asys.singleserver.server.jvm.args", null),
|
||||||
}
|
configuration.getProperty("asys.singleserver.server.params", null));
|
||||||
|
|
||||||
mcServer = new MinecraftWinServer(serverPath, mainJar,
|
|
||||||
getProperty("asys.singleserver.server.jvm.args", null),
|
|
||||||
getProperty("asys.singleserver.server.params", null));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,9 +59,17 @@ public class SingleServer implements IServerManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IMinecraftServer getServer(String serverName) {
|
public IMinecraftServer getServer(String serverName) {
|
||||||
|
if (mcServer == null) {
|
||||||
|
prepareMcServer();
|
||||||
|
}
|
||||||
return mcServer;
|
return mcServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeServer(String name) {
|
||||||
|
mcServer = null;
|
||||||
|
}
|
||||||
|
|
||||||
void loadState() {
|
void loadState() {
|
||||||
ICore core = SingleServerActivator.instance.getCore();
|
ICore core = SingleServerActivator.instance.getCore();
|
||||||
IMinecraftServer testMcServer = (IMinecraftServer) core.loadObject(SingleServer.class.getName() + "#mcServer");
|
IMinecraftServer testMcServer = (IMinecraftServer) core.loadObject(SingleServer.class.getName() + "#mcServer");
|
||||||
@@ -71,16 +82,4 @@ public class SingleServer implements IServerManager {
|
|||||||
ICore core = SingleServerActivator.instance.getCore();
|
ICore core = SingleServerActivator.instance.getCore();
|
||||||
core.saveObject(SingleServer.class.getName() + "#mcServer", mcServer);
|
core.saveObject(SingleServer.class.getName() + "#mcServer", mcServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getProperty(String name) {
|
|
||||||
return getProperty(name, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getProperty(String name, String defValue) {
|
|
||||||
try {
|
|
||||||
return bundleContext.getProperty(name);
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
return defValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,18 @@ package asys.singleserver;
|
|||||||
|
|
||||||
import asys.core.api.ICore;
|
import asys.core.api.ICore;
|
||||||
import asys.core.api.IServerManager;
|
import asys.core.api.IServerManager;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.osgi.framework.BundleActivator;
|
import org.osgi.framework.BundleActivator;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
import org.osgi.framework.ServiceRegistration;
|
import org.osgi.framework.ServiceRegistration;
|
||||||
import org.osgi.util.tracker.ServiceTracker;
|
import org.osgi.util.tracker.ServiceTracker;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
public class SingleServerActivator implements BundleActivator {
|
public class SingleServerActivator implements BundleActivator {
|
||||||
static SingleServerActivator instance;
|
static SingleServerActivator instance;
|
||||||
private ServiceRegistration<?> service, cmdService;
|
private ServiceRegistration<?> service, cmdService;
|
||||||
@@ -24,13 +31,13 @@ public class SingleServerActivator implements BundleActivator {
|
|||||||
tracker = new ServiceTracker<>(bundleContext, ICore.class.getName(), null);
|
tracker = new ServiceTracker<>(bundleContext, ICore.class.getName(), null);
|
||||||
tracker.open();
|
tracker.open();
|
||||||
|
|
||||||
singleServer = new SingleServer(bundleContext);
|
singleServer = new SingleServer(loadProperties(getProperty(bundleContext, "asys.core.config.dir", "conf")));
|
||||||
singleServer.loadState();
|
singleServer.loadState();
|
||||||
service = bundleContext.registerService(IServerManager.class.getName(), singleServer, null);
|
service = bundleContext.registerService(IServerManager.class.getName(), singleServer, null);
|
||||||
|
|
||||||
// Регистрация комманд для Gogo Shell
|
// Регистрация комманд для Gogo Shell
|
||||||
cmdService = bundleContext.registerService(
|
cmdService = bundleContext.registerService(
|
||||||
Commands.class.getName(), new Commands(singleServer), Commands.getDictionary());
|
Commands.class.getName(), new Commands(singleServer), Commands.getProps("asys.server"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,4 +52,51 @@ public class SingleServerActivator implements BundleActivator {
|
|||||||
ICore getCore() {
|
ICore getCore() {
|
||||||
return tracker.getService();
|
return tracker.getService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Properties loadProperties(String confDir) {
|
||||||
|
Path propsPath = Paths.get(confDir).resolve("asys.singleserver.properties");
|
||||||
|
if (Files.notExists(propsPath)) {
|
||||||
|
propsPath.toFile().getParentFile().mkdirs();
|
||||||
|
|
||||||
|
InputStream resourceAsStream = getClass().getResourceAsStream("/asys.singleserver.properties");
|
||||||
|
try {
|
||||||
|
BufferedWriter bw = new BufferedWriter(new FileWriter(propsPath.toFile()));
|
||||||
|
BufferedReader br = new BufferedReader(new InputStreamReader(resourceAsStream));
|
||||||
|
String line;
|
||||||
|
while((line = br.readLine()) != null) {
|
||||||
|
bw.write(line);
|
||||||
|
bw.write("\n");
|
||||||
|
}
|
||||||
|
bw.flush();
|
||||||
|
bw.close();
|
||||||
|
br.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Properties properties = new Properties();
|
||||||
|
try {
|
||||||
|
properties.load(new FileReader(propsPath.toFile()));
|
||||||
|
return properties;
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getProperty(BundleContext bundleContext, String name) {
|
||||||
|
return getProperty(bundleContext, name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getProperty(BundleContext bundleContext, String name, String defValue) {
|
||||||
|
try {
|
||||||
|
String result = bundleContext.getProperty(name);
|
||||||
|
if (result == null) return defValue;
|
||||||
|
else return result;
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
return defValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
asys.singleserver.server.path=server
|
||||||
|
|
||||||
|
asys.singleserver.typeImplement=process
|
||||||
|
asys.singleserver.server.mainjar=spigot.jar
|
||||||
|
asys.singleserver.server.jvm.args="-Dfile.encoding=UTF-8"
|
||||||
|
asys.singleserver.server.params=
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <mail@dmitriymx.ru>
|
||||||
|
* 2016-08-11
|
||||||
|
*/
|
||||||
|
package asys.singleserver;
|
||||||
|
|
||||||
|
import asys.core.api.IMinecraftServer;
|
||||||
|
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
|
public class TestMinectaftScreenServer {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
IMinecraftServer server = new MinecraftScreenServer(
|
||||||
|
"test",
|
||||||
|
Paths.get("D:\\tmp\\spigot_test"),
|
||||||
|
Paths.get("D:\\tmp\\spigot_test\\spigot-1.8.8.jar"),
|
||||||
|
"", "");
|
||||||
|
server.start();
|
||||||
|
System.out.println(String.format("isAlive: %s", server.isAlive()));
|
||||||
|
try {
|
||||||
|
Thread.sleep(30000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
server.stop();
|
||||||
|
try {
|
||||||
|
Thread.sleep(5000);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
}
|
||||||
|
System.out.println(String.format("isAlive: %s", server.isAlive()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <mail@dmitriymx.ru>
|
||||||
|
* 2016-07-30
|
||||||
|
*/
|
||||||
|
package asys.singleserver;
|
||||||
|
|
||||||
|
import asys.core.api.IMinecraftServer;
|
||||||
|
import asys.core.api.IServerManager;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
public class TestSingleServer {
|
||||||
|
@Test
|
||||||
|
public void testAutorun() throws InterruptedException {
|
||||||
|
BundleContext mockBundleContext = mock(BundleContext.class);
|
||||||
|
when(mockBundleContext.getProperty("asys.singleserver.server.path")).thenReturn("D:\\tmp\\spigot_test");
|
||||||
|
when(mockBundleContext.getProperty("asys.singleserver.server.mainjar")).thenReturn("spigot-1.8.8.jar");
|
||||||
|
when(mockBundleContext.getProperty("asys.singleserver.server.jvm.args")).thenReturn("-Dserver.name=\\\"Minecraft Server\\\" -Dfile.encoding=UTF-8");
|
||||||
|
|
||||||
|
IServerManager serverManager = new SingleServer(mockBundleContext);
|
||||||
|
IMinecraftServer server = serverManager.getServer(null);
|
||||||
|
server.start();
|
||||||
|
Assert.assertTrue(server.isAlive());
|
||||||
|
for (int i = 0; i < 7; i++) Thread.sleep(1000);
|
||||||
|
server.stop();
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
if (server.isAlive()) {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (server.isAlive()) {
|
||||||
|
server.forceStop();
|
||||||
|
for (int i = 0; i < 5; i++) Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
Assert.assertFalse(server.isAlive());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<name>Core</name>
|
<name>Core</name>
|
||||||
|
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>0.18</version>
|
<version>0.21</version>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
18
core/src/main/java/asys/core/api/AccessPolicy.java
Normal file
18
core/src/main/java/asys/core/api/AccessPolicy.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <mail@dmitriymx.ru>
|
||||||
|
* 2016-08-14
|
||||||
|
*/
|
||||||
|
package asys.core.api;
|
||||||
|
|
||||||
|
public enum AccessPolicy {
|
||||||
|
EVERYONE(3), PERMISSIONED(2), ADMIN(1), NO_ONE(0);
|
||||||
|
|
||||||
|
int id;
|
||||||
|
AccessPolicy(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,9 +5,10 @@
|
|||||||
package asys.core.api;
|
package asys.core.api;
|
||||||
|
|
||||||
public interface IMinecraftServer {
|
public interface IMinecraftServer {
|
||||||
|
String getName();
|
||||||
void start();
|
void start();
|
||||||
void stop();
|
void stop();
|
||||||
void forceStop();
|
void forceStop();
|
||||||
boolean isAlive();
|
|
||||||
void sendCommand(String command);
|
void sendCommand(String command);
|
||||||
|
boolean isAlive();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
package asys.core.api;
|
package asys.core.api;
|
||||||
|
|
||||||
public interface IServerManager {
|
public interface IServerManager {
|
||||||
IMinecraftServer developServer(String serverName);
|
IMinecraftServer developServer(String name);
|
||||||
IMinecraftServer getServer(String serverName);
|
IMinecraftServer getServer(String name);
|
||||||
|
void removeServer(String name);
|
||||||
}
|
}
|
||||||
|
|||||||
69
core/src/test/java/asys/core/TestAppRunner.java
Normal file
69
core/src/test/java/asys/core/TestAppRunner.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* DmitriyMX <mail@dmitriymx.ru>
|
||||||
|
* 2016-07-29
|
||||||
|
*/
|
||||||
|
package asys.core;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class TestAppRunner {
|
||||||
|
public static void main(String[] args) throws IOException, InterruptedException {
|
||||||
|
// ProcessBuilder processBuilder = new ProcessBuilder("cmd.exe", "/c", "ping 127.0.0.1 -t");
|
||||||
|
ProcessBuilder processBuilder = new ProcessBuilder("java.exe", "-jar", "spigot-1.8.8.jar");
|
||||||
|
processBuilder.directory(Paths.get("D:\\tmp\\spigot_test").toFile());
|
||||||
|
final Process process = processBuilder.start();
|
||||||
|
final boolean[] res = new boolean[1];
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
Pattern pattern = Pattern.compile("Done \\(.+?\\)! For help, type \"help\" or \"\\?\"");
|
||||||
|
InputStream inputStream = process.getInputStream();
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
|
String line;
|
||||||
|
try {
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
System.out.println(System.currentTimeMillis() + " " + line);
|
||||||
|
Matcher matcher = pattern.matcher(line);
|
||||||
|
if (matcher.find()) {
|
||||||
|
System.err.println(System.currentTimeMillis() + " " + "GOTCHA!!!");
|
||||||
|
res[0] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
new Thread(() -> {
|
||||||
|
InputStream inputStream = process.getErrorStream();
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
||||||
|
String line;
|
||||||
|
try {
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
System.err.println(line);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
|
while(!res[0]) {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// OutputStream outputStream = process.getOutputStream();
|
||||||
|
// for(int i = 0; i < 10; i++) {
|
||||||
|
// outputStream.write("echo hello\n".getBytes());
|
||||||
|
// outputStream.flush();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// outputStream.write("stop\n".getBytes());
|
||||||
|
// outputStream.flush();
|
||||||
|
|
||||||
|
process.waitFor();
|
||||||
|
}
|
||||||
|
}
|
||||||
7
pom.xml
7
pom.xml
@@ -27,6 +27,7 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>core</module>
|
<module>core</module>
|
||||||
<module>singleserver</module>
|
<module>singleserver</module>
|
||||||
|
<module>multiserver</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -46,6 +47,12 @@
|
|||||||
<version>4.12</version>
|
<version>4.12</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<version>2.0.99-beta</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-jdk14</artifactId>
|
<artifactId>slf4j-jdk14</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user