aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/debug_receiver/debug_receiver.cpp
blob: 23b02d10033da368b38da4fa874dbfc172c70dac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "debug_receiver_handler.h"
#include "debug_receiver_proto.h"

#include <library/cpp/messagebus/ybus.h>

#include <library/cpp/getopt/last_getopt.h>
#include <library/cpp/lwtrace/all.h>

using namespace NBus;

int main(int argc, char** argv) {
    NLWTrace::StartLwtraceFromEnv();

    TBusQueueConfig queueConfig;
    TBusServerSessionConfig sessionConfig;

    NLastGetopt::TOpts opts;

    queueConfig.ConfigureLastGetopt(opts);
    sessionConfig.ConfigureLastGetopt(opts);

    opts.AddLongOption("port").Required().RequiredArgument("PORT").StoreResult(&sessionConfig.ListenPort);

    opts.SetFreeArgsMax(0);

    NLastGetopt::TOptsParseResult r(&opts, argc, argv);

    TBusMessageQueuePtr q(CreateMessageQueue(queueConfig));

    TDebugReceiverProtocol proto;
    TDebugReceiverHandler handler;

    TBusServerSessionPtr serverSession = TBusServerSession::Create(&proto, &handler, sessionConfig, q);
    // TODO: race is here
    handler.ServerSession = serverSession.Get();

    for (;;) {
        Sleep(TDuration::Hours(17));
    }

    return 0;
}