]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/messenger/simple_server.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2013 CohortFS, LLC
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #include <sys/types.h>
22 #include "common/config.h"
23 #include "msg/Messenger.h"
24 #include "common/Timer.h"
25 #include "common/ceph_argparse.h"
26 #include "global/global_init.h"
27 #include "global/signal_handler.h"
28 #include "perfglue/heap_profiler.h"
29 #include "common/address_helper.h"
30 #include "simple_dispatcher.h"
32 #define dout_subsys ceph_subsys_simple_server
35 int main(int argc
, const char **argv
)
37 vector
<const char*> args
;
39 Dispatcher
*dispatcher
;
40 std::vector
<const char*>::iterator arg_iter
;
42 entity_addr_t bind_addr
;
47 std::string addr
= "localhost";
48 std::string port
= "1234";
50 cout
<< "Simple Server starting..." << endl
;
52 argv_to_vec(argc
, argv
, args
);
55 auto cct
= global_init(NULL
, args
, CEPH_ENTITY_TYPE_ANY
,
56 CODE_ENVIRONMENT_DAEMON
,
59 for (arg_iter
= args
.begin(); arg_iter
!= args
.end();) {
60 if (ceph_argparse_witharg(args
, arg_iter
, &val
, "--addr",
63 } else if (ceph_argparse_witharg(args
, arg_iter
, &val
, "--port",
71 string dest_str
= "tcp://";
75 entity_addr_from_url(&bind_addr
, dest_str
.c_str());
77 messenger
= Messenger::create(g_ceph_context
, g_conf
->get_val
<std::string
>("ms_type"),
78 entity_name_t::MON(-1),
82 // enable timing prints
83 messenger
->set_magic(MSG_MAGIC_TRACE_CTR
);
84 messenger
->set_default_policy(
85 Messenger::Policy::stateless_server(0));
87 r
= messenger
->bind(bind_addr
);
91 // Set up crypto, daemonize, etc.
92 //global_init_daemonize(g_ceph_context, 0);
93 common_init_finish(g_ceph_context
);
95 dispatcher
= new SimpleDispatcher(messenger
);
97 messenger
->add_dispatcher_head(dispatcher
); // should reach ready()
99 messenger
->wait(); // can't be called until ready()
105 cout
<< "Simple Server exit" << endl
;