17
17
import convex .peer .API ;
18
18
import convex .peer .ConfigException ;
19
19
import convex .peer .Server ;
20
+ import convex .restapi .RESTServer ;
20
21
import etch .EtchStore ;
21
22
import picocli .CommandLine .Command ;
22
23
import picocli .CommandLine .Mixin ;
@@ -57,6 +58,14 @@ public class PeerStart extends APeerCommand {
57
58
58
59
@ Option (names = { "--url" }, description = "URL for the peer to publish. If not provided, the peer will have no public URL." )
59
60
private String url ;
61
+
62
+ @ Option (names = { "--norest" }, description = "Disable REST srever." )
63
+ private boolean norest ;
64
+
65
+ @ Option (names = { "--api-port" }, description = "Port for REST API." )
66
+ private Integer apiport ;
67
+
68
+
60
69
61
70
// @Option(names = { "-b",
62
71
// "--bind-address" }, description = "Bind address of the network interface. Defaults to local loop back device for %n"
@@ -121,12 +130,18 @@ public void run() {
121
130
122
131
}
123
132
133
+ RESTServer restServer =null ;;
124
134
try {
125
135
HashMap <Keyword ,Object > config =new HashMap <>();
126
136
config .put (Keywords .KEYPAIR , peerKey );
127
137
config .put (Keywords .STORE , store );
128
- Server s =API .launchPeer (config );
129
- while (s .isRunning ()&&!Thread .currentThread ().isInterrupted ()) {
138
+ Server server =API .launchPeer (config );
139
+
140
+ restServer =RESTServer .create (server );
141
+ restServer .start (apiport );
142
+
143
+
144
+ while (server .isRunning ()&&!Thread .currentThread ().isInterrupted ()) {
130
145
Thread .sleep (400 );
131
146
}
132
147
informSuccess ("Peer shutdown completed" );
@@ -135,6 +150,8 @@ public void run() {
135
150
} catch (InterruptedException e ) {
136
151
informWarning ("Peer interrupted before normal shutdown" );
137
152
return ;
153
+ } finally {
154
+ if (restServer !=null ) restServer .stop ();
138
155
}
139
156
}
140
157
}
0 commit comments