Mercurial > malikania
annotate server/main.cpp @ 192:74afc5a41c83
Common: rewrite socket class, closes #911 @2h
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 27 Oct 2018 07:11:03 +0200 |
parents | ffe8ac5c35c0 |
children |
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 * |
158
4b292c20124c
Misc: update copyrights
David Demelier <markand@malikania.fr>
parents:
154
diff
changeset
|
4 * Copyright (c) 2013-2018 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 |
169
450d884456c4
Server: initial re-support of PostgreSQL
David Demelier <markand@malikania.fr>
parents:
165
diff
changeset
|
19 #include <iostream> |
450d884456c4
Server: initial re-support of PostgreSQL
David Demelier <markand@malikania.fr>
parents:
165
diff
changeset
|
20 |
179
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
21 #include <malikania/db/database.hpp> |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
22 #include <malikania/db/account.hpp> |
169
450d884456c4
Server: initial re-support of PostgreSQL
David Demelier <markand@malikania.fr>
parents:
165
diff
changeset
|
23 |
171 | 24 #include <malikania/server/server.hpp> |
25 | |
26 using namespace mlk; | |
169
450d884456c4
Server: initial re-support of PostgreSQL
David Demelier <markand@malikania.fr>
parents:
165
diff
changeset
|
27 |
42
a47a4477f347
Misc: new style, closes #578
David Demelier <markand@malikania.fr>
parents:
33
diff
changeset
|
28 int main() |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
29 { |
179
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
30 boost::asio::io_context ctx; |
171 | 31 |
179
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
32 try { |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
33 server::settings settings; |
169
450d884456c4
Server: initial re-support of PostgreSQL
David Demelier <markand@malikania.fr>
parents:
165
diff
changeset
|
34 |
179
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
35 settings.key = "/home/markand/server.key"; |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
36 settings.certificate = "/home/markand/server.crt"; |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
37 settings.port = 3320; |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
38 |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
39 server::server sv(ctx, settings); |
175
a23758dda37d
Server: implement authentication, closes #869
David Demelier <markand@malikania.fr>
parents:
171
diff
changeset
|
40 |
179
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
41 db::open("", "", "markand", "malikaniadb", ""); |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
42 db::init(); |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
43 |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
44 ctx.run(); |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
45 } catch (const std::exception& ex) { |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
46 std::cerr << "abort: " << ex.what() << std::endl; |
ffe8ac5c35c0
Database: implement as a separate library, closes #906 @1h
David Demelier <markand@malikania.fr>
parents:
175
diff
changeset
|
47 } |
33
d4f5f7231b84
Misc: switch to .hpp, dos2unix everything while here, #478
David Demelier <markand@malikania.fr>
parents:
30
diff
changeset
|
48 } |