summaryrefslogtreecommitdiffhomepage
path: root/mullvad-daemon/src/cli.rs
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-04-19 18:55:31 +0200
committerAndrej Mihajlov <and@mullvad.net>2018-04-23 21:51:59 +0200
commit308832d0df052dd4433bda2cc5c586ca9745c249 (patch)
treefb923fc7a264149837fe36d442b920bed8874a48 /mullvad-daemon/src/cli.rs
parent8f6f61ebd6a013f657a2523dbe4b4cfa1a1cb462 (diff)
downloadmullvadvpn-308832d0df052dd4433bda2cc5c586ca9745c249.tar.xz
mullvadvpn-308832d0df052dd4433bda2cc5c586ca9745c249.zip
Add basic windows service
Diffstat (limited to 'mullvad-daemon/src/cli.rs')
-rw-r--r--mullvad-daemon/src/cli.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/mullvad-daemon/src/cli.rs b/mullvad-daemon/src/cli.rs
index f3c5773912..f70d69f947 100644
--- a/mullvad-daemon/src/cli.rs
+++ b/mullvad-daemon/src/cli.rs
@@ -12,6 +12,8 @@ pub struct Config {
pub resource_dir: Option<PathBuf>,
pub require_auth: bool,
pub log_stdout_timestamps: bool,
+ pub run_as_service: bool,
+ pub register_service: bool,
}
pub fn get_config() -> Config {
@@ -29,6 +31,9 @@ pub fn get_config() -> Config {
let require_auth = !matches.is_present("disable_rpc_auth");
let log_stdout_timestamps = !matches.is_present("disable_stdout_timestamps");
+ let run_as_service = cfg!(windows) && matches.is_present("run_as_service");
+ let register_service = cfg!(windows) && matches.is_present("register_service");
+
Config {
log_level,
log_file,
@@ -36,11 +41,13 @@ pub fn get_config() -> Config {
resource_dir,
require_auth,
log_stdout_timestamps,
+ run_as_service,
+ register_service,
}
}
fn create_app() -> App<'static, 'static> {
- App::new(crate_name!())
+ let app = App::new(crate_name!())
.version(version::current())
.author(crate_authors!())
.about(crate_description!())
@@ -80,5 +87,19 @@ fn create_app() -> App<'static, 'static> {
Arg::with_name("disable_stdout_timestamps")
.long("disable-stdout-timestamps")
.help("Don't log timestamps when logging to stdout, useful when running as a systemd service")
- )
+ );
+
+ if cfg!(windows) {
+ app.arg(
+ Arg::with_name("run_as_service")
+ .long("run-as-service")
+ .help("Run as a system service. On Windows this option must be used when running a system service"),
+ ).arg(
+ Arg::with_name("register_service")
+ .long("register-service")
+ .help("Register itself as a system service"),
+ )
+ } else {
+ app
+ }
}