42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
// Copyright (2019-2022) Paul Scherrer Institute
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include <fstream>
|
|
#include <nlohmann/json.hpp>
|
|
|
|
#include "HDF5Objects.h"
|
|
#include "../grpc/gRPCServer_Template.h"
|
|
#include "../common/Logger.h"
|
|
#include "JFJochWriterService.h"
|
|
|
|
int main(int argc, char **argv) {
|
|
RegisterHDF5Filter();
|
|
|
|
Logger logger("jfjoch_writer");
|
|
|
|
if (argc < 3) {
|
|
logger.Error("Usage ./jfjoch_writer <json config file> <gRPC port>");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
std::string grpc_addr = "0.0.0.0:" + std::string(argv[2]);
|
|
|
|
nlohmann::json input;
|
|
std::ifstream file(argv[1]);
|
|
try {
|
|
input = nlohmann::json::parse(file);
|
|
} catch (const nlohmann::json::exception &e) {
|
|
logger.Error("JSON Parsing exception: " + std::string(e.what()));
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
ZMQContext context;
|
|
JFJochWriterService service(context, logger);
|
|
|
|
if (input.contains("base_directory"))
|
|
service.BaseDirectory(input["base_directory"]);
|
|
|
|
auto server = gRPCServer(grpc_addr, service);
|
|
logger.Info("gRPC configuration listening on address " + grpc_addr);
|
|
server->Wait();
|
|
} |