1 /*************************************************************************
6 * [2011] - [2015] Realm Inc
9 * NOTICE: All information contained herein is, and remains
10 * the property of Realm Incorporated and its suppliers,
11 * if any. The intellectual and technical concepts contained
12 * herein are proprietary to Realm Incorporated
13 * and its suppliers and may be covered by U.S. and Foreign Patents,
14 * patents in process, and are protected by trade secret or copyright law.
15 * Dissemination of this information or reproduction of this material
16 * is strictly forbidden unless prior written permission is obtained
17 * from Realm Incorporated.
19 **************************************************************************/
20 #ifndef REALM_SYNC_SERVER_CONFIGURATION_HPP
21 #define REALM_SYNC_SERVER_CONFIGURATION_HPP
26 #include <realm/util/logger.hpp>
27 #include <realm/util/optional.hpp>
28 #include <realm/sync/server.hpp>
33 struct Configuration {
35 std::string listen_address = "127.0.0.1";
36 std::string listen_port = ""; // Empty means choose default based on `ssl`.
37 realm::util::Optional<std::string> root_dir;
38 std::string user_data_dir;
39 realm::util::Optional<std::string> public_key_path;
40 realm::util::Optional<std::string> config_file_path;
41 bool reuse_address = true;
42 bool disable_sync = false;
43 realm::util::Logger::Level log_level = realm::util::Logger::Level::info;
44 realm::util::Optional<std::string> log_path;
45 long max_open_files = 256;
47 std::string ssl_certificate_path;
48 std::string ssl_certificate_key_path;
49 std::string dashboard_stats_endpoint = "localhost:28125";
50 uint_fast64_t drop_period_s = 60; // 1 minute
51 uint_fast64_t idle_timeout_s = 1800; // 30 minutes
52 realm::sync::Server::Config::OperatingMode operating_mode =
53 realm::sync::Server::Config::OperatingMode::MasterWithNoSlave;
54 std::string master_address;
55 std::string master_port;
56 bool master_slave_ssl = false;
57 bool master_verify_ssl_certificate = true;
58 util::Optional<std::string> master_ssl_trust_certificate_path;
59 std::string master_slave_shared_secret;
60 util::Optional<std::string> feature_token;
61 util::Optional<std::string> feature_token_path;
62 bool enable_download_log_compaction = true;
63 size_t max_download_size = 0x20000; // 128 KiB
67 void show_help(const std::string& program_name);
68 Configuration build_configuration(int argc, char* argv[]);
70 Configuration load_configuration(std::string configuration_file_path);
77 /// Initialise the directory structure as required (create missing directory
78 /// structure) for correct operation of the server. This function is supposed to
79 /// be executed prior to instantiating the \c Server object.
81 /// Note: This function also handles migration of server-side Realm files from
82 /// the legacy format (see _impl::ensure_legacy_migration_1()).
84 /// The type of migration performed by this function is nonatomic, and it
85 /// therefore requires that no other thread or process has any of the servers
86 /// Realm files open concurrently. The application is advised to make sure that
87 /// all agents (including the sync server), that might open server-side Realm
88 /// files are not started until after this function has completed sucessfully.
89 void prepare_server_directory(const config::Configuration&, util::Logger&);
94 #endif // REALM_SYNC_SERVER_CONFIGURATION_HPP