Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sslocal, ssservice, ssmanager return non-zero exit codes when failing to launch #874

Merged
merged 1 commit into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ pub mod service;
pub mod sys;
pub mod validator;

/// Exit code when server exits unexpectly
/// Exit code when server exits unexpectedly
pub const EXIT_CODE_SERVER_EXIT_UNEXPECTEDLY: sysexits::ExitCode = sysexits::ExitCode::Software;
/// Exit code when server aborted
pub const EXIT_CODE_SERVER_ABORTED: sysexits::ExitCode = sysexits::ExitCode::Software;
/// Exit code when loading configuration from file fails
pub const EXIT_CODE_LOAD_CONFIG_FAILURE: sysexits::ExitCode = sysexits::ExitCode::Config;
/// Exit code when loading ACL from file fails
pub const EXIT_CODE_LOAD_ACL_FAILURE: sysexits::ExitCode = sysexits::ExitCode::Config;
/// Exit code when insufficient params are passed via CLI
pub const EXIT_CODE_INSUFFICIENT_PARAMS: sysexits::ExitCode = sysexits::ExitCode::Usage;

/// Build timestamp in UTC
pub const BUILD_TIME: &str = build_time::build_time_utc!();
Expand Down
7 changes: 3 additions & 4 deletions src/service/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ use shadowsocks_service::{
use crate::logging;
use crate::{
config::{Config as ServiceConfig, RuntimeMode},
monitor,
validator,
monitor, validator,
};

/// Defines command line options
Expand Down Expand Up @@ -763,12 +762,12 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
"missing `local_address`, consider specifying it by --local-addr command line option, \
or \"local_address\" and \"local_port\" in configuration file"
);
return ExitCode::SUCCESS;
return crate::EXIT_CODE_INSUFFICIENT_PARAMS.into();
}

if let Err(err) = config.check_integrity() {
eprintln!("config integrity check failed, {}", err);
return ExitCode::SUCCESS;
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
}

#[cfg(unix)]
Expand Down
7 changes: 3 additions & 4 deletions src/service/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ use shadowsocks_service::{
use crate::logging;
use crate::{
config::{Config as ServiceConfig, RuntimeMode},
monitor,
validator,
monitor, validator,
};

/// Defines command line options
Expand Down Expand Up @@ -435,12 +434,12 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
"missing `manager_address`, consider specifying it by --manager-address command line option, \
or \"manager_address\" and \"manager_port\" keys in configuration file"
);
return ExitCode::SUCCESS;
return crate::EXIT_CODE_INSUFFICIENT_PARAMS.into();
}

if let Err(err) = config.check_integrity() {
eprintln!("config integrity check failed, {}", err);
return ExitCode::SUCCESS;
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
}

#[cfg(unix)]
Expand Down
7 changes: 3 additions & 4 deletions src/service/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ use shadowsocks_service::{
use crate::logging;
use crate::{
config::{Config as ServiceConfig, RuntimeMode},
monitor,
validator,
monitor, validator,
};

/// Defines command line options
Expand Down Expand Up @@ -448,12 +447,12 @@ pub fn main(matches: &ArgMatches) -> ExitCode {
--server-addr, --encrypt-method, --password command line option, \
or configuration file, check more details in https://shadowsocks.org/en/config/quick-guide.html"
);
return ExitCode::SUCCESS;
return crate::EXIT_CODE_INSUFFICIENT_PARAMS.into();
}

if let Err(err) = config.check_integrity() {
eprintln!("config integrity check failed, {}", err);
return ExitCode::SUCCESS;
return crate::EXIT_CODE_LOAD_CONFIG_FAILURE.into();
}

#[cfg(unix)]
Expand Down