annotate server/main.cpp @ 121:48f7e7277ab6

CMake: set CMake variables in libraries
author David Demelier <markand@malikania.fr>
date Fri, 22 Sep 2017 12:56:55 +0200
parents 119bcc5a727e
children 614ac46dac3e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
1 /*
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
2 * main.cpp -- main server executable file
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
3 *
110
119bcc5a727e Misc: replace copyrights, closes #655
David Demelier <markand@malikania.fr>
parents: 101
diff changeset
4 * Copyright (c) 2013-2017 David Demelier <markand@malikania.fr>
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
5 *
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
6 * Permission to use, copy, modify, and/or distribute this software for any
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
7 * purpose with or without fee is hereby granted, provided that the above
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
8 * copyright notice and this permission notice appear in all copies.
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
9 *
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
17 */
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
18
46
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
19 #include <iostream>
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
20
101
51dd7a4914ec Server: add database stubs, #687 @1h
David Demelier <markand@malikania.fr>
parents: 92
diff changeset
21 #include <malikania/server/db/dynlib_database.hpp>
83
d458af0b7748 Server: namespace and hierarchy
David Demelier <markand@malikania.fr>
parents: 76
diff changeset
22 #include <malikania/server/server.hpp>
46
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
23
42
a47a4477f347 Misc: new style, closes #578
David Demelier <markand@malikania.fr>
parents: 33
diff changeset
24 int main()
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
25 {
101
51dd7a4914ec Server: add database stubs, #687 @1h
David Demelier <markand@malikania.fr>
parents: 92
diff changeset
26 #if 0
92
4031eda60e11 Misc: switch to JSON, #650
David Demelier <markand@malikania.fr>
parents: 83
diff changeset
27 mlk::server::settings sv_params{
4031eda60e11 Misc: switch to JSON, #650
David Demelier <markand@malikania.fr>
parents: 83
diff changeset
28 3320,
4031eda60e11 Misc: switch to JSON, #650
David Demelier <markand@malikania.fr>
parents: 83
diff changeset
29 "/home/markand/null/server.crt",
4031eda60e11 Misc: switch to JSON, #650
David Demelier <markand@malikania.fr>
parents: 83
diff changeset
30 "/home/markand/null/server.key",
4031eda60e11 Misc: switch to JSON, #650
David Demelier <markand@malikania.fr>
parents: 83
diff changeset
31 };
46
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
32
101
51dd7a4914ec Server: add database stubs, #687 @1h
David Demelier <markand@malikania.fr>
parents: 92
diff changeset
33 mlk::server::dynlib_database db({
92
4031eda60e11 Misc: switch to JSON, #650
David Demelier <markand@malikania.fr>
parents: 83
diff changeset
34 { "type", "sqlite" },
4031eda60e11 Misc: switch to JSON, #650
David Demelier <markand@malikania.fr>
parents: 83
diff changeset
35 { "path", "/home/markand/kingdom.db" }
4031eda60e11 Misc: switch to JSON, #650
David Demelier <markand@malikania.fr>
parents: 83
diff changeset
36 });
46
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
37
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
38 boost::asio::io_service service;
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
39
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
40 try {
92
4031eda60e11 Misc: switch to JSON, #650
David Demelier <markand@malikania.fr>
parents: 83
diff changeset
41 mlk::server::server server(service, db, sv_params);
46
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
42
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
43 for (;;) {
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
44 service.run();
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
45 }
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
46 } catch (const std::exception& ex) {
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
47 std::cerr << "fatal: " << ex.what() << std::endl;
b0593a3e2ca8 Server: use Boost.Asio and add basic authentication support
David Demelier <markand@malikania.fr>
parents: 42
diff changeset
48 }
101
51dd7a4914ec Server: add database stubs, #687 @1h
David Demelier <markand@malikania.fr>
parents: 92
diff changeset
49 #endif
33
d4f5f7231b84 Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents: 30
diff changeset
50 }