-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5202 from ghubstan/01-api-method-stop
Add api method 'stop'
- Loading branch information
Showing
7 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,5 +53,6 @@ public enum Method { | |
takeoffer, | ||
unlockwallet, | ||
unsettxfeerate, | ||
withdrawfunds | ||
withdrawfunds, | ||
stop | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
stop | ||
|
||
NAME | ||
---- | ||
stop - stop the server | ||
|
||
SYNOPSIS | ||
-------- | ||
stop | ||
|
||
DESCRIPTION | ||
----------- | ||
Shutdown the RPC server. | ||
|
||
OPTIONS | ||
------- | ||
|
||
EXAMPLES | ||
-------- | ||
To shutdown the server: | ||
$ ./bisq-cli --password=xyz --port=9998 stop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
daemon/src/main/java/bisq/daemon/grpc/GrpcShutdownService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* This file is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package bisq.daemon.grpc; | ||
|
||
import bisq.core.app.BisqHeadlessApp; | ||
|
||
import bisq.common.UserThread; | ||
|
||
import bisq.proto.grpc.ShutdownServerGrpc; | ||
import bisq.proto.grpc.StopReply; | ||
import bisq.proto.grpc.StopRequest; | ||
|
||
import io.grpc.stub.StreamObserver; | ||
|
||
import javax.inject.Inject; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import static java.util.concurrent.TimeUnit.MILLISECONDS; | ||
|
||
@Slf4j | ||
class GrpcShutdownService extends ShutdownServerGrpc.ShutdownServerImplBase { | ||
|
||
private final GrpcExceptionHandler exceptionHandler; | ||
|
||
@Inject | ||
public GrpcShutdownService(GrpcExceptionHandler exceptionHandler) { | ||
this.exceptionHandler = exceptionHandler; | ||
} | ||
|
||
@Override | ||
public void stop(StopRequest req, | ||
StreamObserver<StopReply> responseObserver) { | ||
try { | ||
log.info("Shutdown request received."); | ||
var reply = StopReply.newBuilder().build(); | ||
responseObserver.onNext(reply); | ||
responseObserver.onCompleted(); | ||
UserThread.runAfter(BisqHeadlessApp.getShutDownHandler(), 500, MILLISECONDS); | ||
} catch (Throwable cause) { | ||
exceptionHandler.handleException(cause, responseObserver); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters