mirror of
https://github.com/nestriness/cdc-file-transfer.git
synced 2026-02-07 23:05:35 +02:00
[cdc_stream] Automatically start service (#28)
Starts the streaming service if it's not up and running. This required adding the ability to run a detached process. By default, all child processes are killed when the parent process exits. Since detached child processes don't run with a console, they need to create sub- processes with CREATE_NO_WINDOW since otherwise a new console pops up, e.g. for every ssh command. Polls for 20 seconds while the service starts up. For this purpose, a BackgroundServiceClient is added. This will be reused in a future CL by a new stop-service command to exit the service. Also adds --service-port as additional argument to start-service.
This commit is contained in:
@@ -21,6 +21,9 @@
|
||||
#include "common/log.h"
|
||||
#include "common/path.h"
|
||||
#include "common/status_macros.h"
|
||||
#include "grpcpp/channel.h"
|
||||
#include "grpcpp/create_channel.h"
|
||||
#include "grpcpp/support/channel_arguments.h"
|
||||
#include "lyra/lyra.hpp"
|
||||
|
||||
namespace cdc_ft {
|
||||
@@ -58,7 +61,13 @@ void StopCommand::RegisterCommandLineFlags(lyra::command& cmd) {
|
||||
absl::Status StopCommand::Run() {
|
||||
LogLevel level = Log::VerbosityToLogLevel(verbosity_);
|
||||
ScopedLog scoped_log(std::make_unique<ConsoleLog>(level));
|
||||
LocalAssetsStreamManagerClient client(service_port_);
|
||||
|
||||
std::string client_address = absl::StrFormat("localhost:%u", service_port_);
|
||||
std::shared_ptr<grpc::Channel> channel = grpc::CreateCustomChannel(
|
||||
client_address, grpc::InsecureChannelCredentials(),
|
||||
grpc::ChannelArguments());
|
||||
|
||||
LocalAssetsStreamManagerClient client(channel);
|
||||
|
||||
std::string user_host, mount_dir;
|
||||
RETURN_IF_ERROR(LocalAssetsStreamManagerClient::ParseUserHostDir(
|
||||
|
||||
Reference in New Issue
Block a user