Skip to content

Commit 162ca28

Browse files
committed
basic-server: make execution more user friendly
Motivation: - expecting user any key to shutdown makes it hard to run as service - mutating name make it hard for scripting Modification: - Update Main class to expect interrupt - fixed name for all-in-one jar Result: simpler to test integrations Acked-by: Marina Sahakyan Target: master
1 parent 5075ab7 commit 162ca28

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

basic-server/pom.xml

+2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
<Build-Time>${maven.build.timestamp}</Build-Time>
4242
</manifestEntries>
4343
</archive>
44+
<finalName>${project.artifactId}</finalName>
45+
<appendAssemblyId>false</appendAssemblyId>
4446
</configuration>
4547
</execution>
4648
</executions>

basic-server/src/main/java/org/dcache/nfs4j/server/Main.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ public class Main implements Callable<Void> {
2424
private boolean withPortmap;
2525

2626
public static void main(String[] args) throws Exception {
27-
new CommandLine(new Main()).execute(args);
27+
int rc = new CommandLine(new Main()).execute(args);
28+
System.exit(rc);
2829
}
2930

30-
public Void call() throws IOException {
31+
public Void call() throws IOException, InterruptedException {
3132

3233
ExportFile exportFile = null;
3334
if (exportsFile != null) {
@@ -39,8 +40,8 @@ public Void call() throws IOException {
3940
}
4041

4142
try (SimpleNfsServer ignored = new SimpleNfsServer(nfsVers, rpcPort, root, exportFile, null)) {
42-
//noinspection ResultOfMethodCallIgnored
43-
System.in.read(); //any key to shutdown
43+
System.out.println("Press Ctrl-C to stop the server...");
44+
Thread.currentThread().join();
4445
}
4546

4647
return null;

0 commit comments

Comments
 (0)