|
1 | | -/* Copyright (c) 2015-2024, EPFL/Blue Brain Project |
| 1 | +/* Copyright (c) 2015-2024 EPFL/Blue Brain Project |
2 | 2 | * All rights reserved. Do not distribute without permission. |
3 | | - * Responsible Author: Cyrille Favreau <[email protected]> |
| 3 | + * |
| 4 | + * Responsible Author: [email protected] |
4 | 5 | * |
5 | 6 | * This file is part of Brayns <https://github.com/BlueBrain/Brayns> |
6 | 7 | * |
7 | | - * This program is free software: you can redistribute it and/or modify |
8 | | - * it under the terms of the GNU General Public License as published by |
9 | | - * the Free Software Foundation, either version 3 of the License, or |
10 | | - * (at your option) any later version. |
| 8 | + * This library is free software; you can redistribute it and/or modify it under |
| 9 | + * the terms of the GNU Lesser General Public License version 3.0 as published |
| 10 | + * by the Free Software Foundation. |
11 | 11 | * |
12 | | - * This program is distributed in the hope that it will be useful, |
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | | - * GNU General Public License for more details. |
| 12 | + * This library is distributed in the hope that it will be useful, but WITHOUT |
| 13 | + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 14 | + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 15 | + * details. |
16 | 16 | * |
17 | | - * You should have received a copy of the GNU General Public License |
18 | | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + * You should have received a copy of the GNU Lesser General Public License |
| 18 | + * along with this library; if not, write to the Free Software Foundation, Inc., |
| 19 | + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
19 | 20 | */ |
20 | 21 |
|
21 | 22 | #include <iostream> |
22 | 23 |
|
23 | | -#include <brayns/core/Brayns.h> |
24 | | -#include <brayns/core/CommandLine.h> |
25 | | -#include <brayns/core/utils/Log.h> |
26 | | -#include <brayns/core/utils/Timer.h> |
27 | | - |
28 | | -#ifdef BRAYNS_ENABLE_CIRCUITS |
29 | | - #include <brayns/circuits/CircuitExplorerPlugin.h> |
30 | | -#endif |
| 24 | +#include <brayns/core/Launcher.h> |
| 25 | +#include <brayns/core/Version.h> |
| 26 | +#include <brayns/core/cli/CommandLine.h> |
31 | 27 |
|
32 | | -#ifdef BRAYNS_ENABLE_ATLAS |
33 | | - #include <brayns/atlas/AtlasExplorerPlugin.h> |
34 | | -#endif |
| 28 | +using namespace brayns::experimental; |
| 29 | +using brayns::getCopyright; |
35 | 30 |
|
36 | 31 | int main(int argc, const char **argv) |
37 | 32 | { |
38 | 33 | try |
39 | 34 | { |
40 | | - auto commandLine = brayns::CommandLine(argc, argv); |
| 35 | + auto settings = parseArgvAs<ServiceSettings>(argc, argv); |
41 | 36 |
|
42 | | - if (commandLine.hasVersion()) |
| 37 | + if (settings.version) |
43 | 38 | { |
44 | | - auto version = commandLine.getVersion(); |
45 | | - std::cout << version << '\n'; |
| 39 | + std::cout << getCopyright() << '\n'; |
46 | 40 | return 0; |
47 | 41 | } |
48 | 42 |
|
49 | | - if (commandLine.hasHelp()) |
| 43 | + if (settings.help) |
50 | 44 | { |
51 | | - auto help = commandLine.getHelp(); |
52 | | - std::cout << help << '\n'; |
| 45 | + std::cout << getArgvHelp<ServiceSettings>() << '\n'; |
53 | 46 | return 0; |
54 | 47 | } |
55 | 48 |
|
56 | | - auto instance = brayns::Brayns(argc, argv); |
57 | | - |
58 | | -#ifdef BRAYNS_ENABLE_CIRCUITS |
59 | | - brayns::loadCircuitExplorer(instance); |
60 | | -#endif |
61 | | - |
62 | | -#ifdef BRAYNS_ENABLE_ATLAS |
63 | | - brayns::loadAtlasExplorer(instance); |
64 | | -#endif |
65 | | - |
66 | | - brayns::Log::info("Starting Brayns service."); |
67 | | - |
68 | | - auto timer = brayns::Timer(); |
69 | | - |
70 | | - instance.runAsService(); |
71 | | - |
72 | | - brayns::Log::info("Service was running for {} seconds.", timer.seconds()); |
| 49 | + runService(settings); |
73 | 50 | } |
74 | 51 | catch (const std::exception &e) |
75 | 52 | { |
76 | | - brayns::Log::fatal("Fatal error: '{}'.", e.what()); |
77 | | - return 1; |
| 53 | + std::cout << "Fatal error: " << e.what() << ".\n"; |
78 | 54 | } |
79 | 55 | catch (...) |
80 | 56 | { |
81 | | - brayns::Log::fatal("Unknown fatal error."); |
| 57 | + std::cout << "Unknown fatal error."; |
82 | 58 | return 1; |
83 | 59 | } |
84 | 60 |
|
|
0 commit comments