Skip to content

Commit a201ee6

Browse files
Introduce the instance name (#44)
1 parent 7817a6b commit a201ee6

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/args.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub const GCS_BUCKET: &str = "sbe-gcs-bucket";
1616
pub const GCS_KEY_FILE: &str = "sbe-gcs-key-file";
1717
pub const HTTP_BIND_ADDRESS: &str = "bind-address-http";
1818
pub const IDLE_SESSION_TIMEOUT: &str = "idle-session-timeout";
19+
pub const INSTANCE_NAME: &str = "instance-name";
1920
pub const PASSIVE_PORTS: &str = "passive-ports";
2021
pub const PROXY_EXTERNAL_CONTROL_PORT: &str = "proxy-external-control-port";
2122
pub const REDIS_HOST: &str = "log-redis-host";
@@ -126,6 +127,15 @@ pub(crate) fn clap_app(tmp_dir: &str) -> clap::App {
126127
.takes_value(true)
127128
.default_value("0.0.0.0:8080"),
128129
)
130+
.arg(
131+
Arg::with_name(INSTANCE_NAME)
132+
.long("instance-name")
133+
.value_name("NAME")
134+
.help("Gives a user friendly name to this instance. This is for used for example as part of the app name during logging.")
135+
.env("UNFTP_INSTANCE_NAME")
136+
.takes_value(true)
137+
.default_value("unFTP"),
138+
)
129139
.arg(
130140
Arg::with_name(PASSIVE_PORTS)
131141
.long("passive-ports")

src/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,13 @@ fn redis_logger(m: &clap::ArgMatches) -> Result<Option<redislog::Logger>, String
4141
m.value_of(args::REDIS_PORT),
4242
) {
4343
(Some(key), Some(host), Some(port)) => {
44-
let logger = redislog::Builder::new(app::NAME)
44+
let instance_name = m.value_of(args::INSTANCE_NAME).unwrap();
45+
let app_name = if instance_name == app::NAME {
46+
String::from(app::NAME)
47+
} else {
48+
format!("{}-{}", app::NAME, instance_name)
49+
};
50+
let logger = redislog::Builder::new(&*app_name)
4551
.redis(
4652
String::from(host),
4753
String::from(port).parse::<u32>().unwrap(),

0 commit comments

Comments
 (0)