Skip to content

Commit

Permalink
optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
ezTxmMC committed Jan 21, 2025
1 parent edcfa89 commit e106b00
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ build/

### Mac OS ###
.DS_Store
/dependency-reduced-pom.xml

###
.LCKpom*
dependency-reduced-pom.xml
test/
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
import java.util.Map;
import java.util.stream.Collectors;

import org.json.JSONException;
import org.json.JSONObject;

import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.Container;
import com.github.dockerjava.core.DefaultDockerClientConfig;
import com.github.dockerjava.core.DockerClientImpl;
import com.github.dockerjava.httpclient5.ApacheDockerHttpClient;
import org.json.JSONException;
import org.json.JSONObject;

public class ServerManager extends Thread {
private final int startPort;
Expand Down Expand Up @@ -160,9 +161,11 @@ private boolean isPortUsedByContainer(int port) {
return true;
}
} catch (IOException e) {
System.err.println("Error while reading file " + serverInfoFile.getAbsolutePath() + ": " + e.getMessage());
System.err.println(
"Error while reading file " + serverInfoFile.getAbsolutePath() + ": " + e.getMessage());
} catch (JSONException e) {
System.err.println("Error while parse file content to json " + serverInfoFile.getAbsolutePath() + ": " + e.getMessage());
System.err.println("Error while parse file content to json " + serverInfoFile.getAbsolutePath() + ": "
+ e.getMessage());
}
}
return false;
Expand Down Expand Up @@ -255,7 +258,8 @@ public void mapping() {
this.serverContainers = new HashMap<>();
this.containerPaths = new HashMap<>();
this.getContainerNamesAndIds().forEach((containerName, containerId) -> {
ServerContainer container = new ServerContainer(this.dockerClient, this.basePath, containerId, containerName.split("2weeksmc-server-")[1]);
ServerContainer container = new ServerContainer(this.dockerClient, this.basePath, containerId,
containerName.split("2weeksmc-server-")[1]);
container.start();
this.serverContainers.put(containerName, container);
this.containerPaths.put(containerName, Path.of(container.getServerPath()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static void main(String[] args) throws IOException {

public DSMRunner() throws IOException {
this.console = new JLineConsole();
this.serverManager = new ServerManager(10000, "E://Desktop/2weeksmc/dms-containers");
this.serverManager = new ServerManager(10000, "/home/eztxmmc/.dsm-containers");
}

public void start() {
Expand Down

0 comments on commit e106b00

Please sign in to comment.