Skip to content

Commit 2b80ae7

Browse files
committed
fix: publish topic and prepare to deploy production environment
1 parent fc18150 commit 2b80ae7

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

agent/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/target
2-
.idea
2+
.idea
3+
config.prod.yml

agent/examples/publish_command.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ async fn main() -> anyhow::Result<()> {
1616
};
1717

1818
let config_path:PathBuf = "./config.yml".parse().unwrap();
19+
let publish_client_id = "test_web";
20+
let password:Option<String> = None;
21+
let username:Option<String> = None;
1922

2023
let is_terminal = std::io::stdout().is_terminal();
2124

@@ -24,8 +27,11 @@ async fn main() -> anyhow::Result<()> {
2427

2528
let config = mproxy::config::Config::new(Some(config_path)).unwrap();
2629

27-
let mqtt_url = format!("{}?client_id={}", &config.server, "test_web");
28-
let options = MqttOptions::parse_url(&mqtt_url).unwrap();
30+
let mqtt_url = format!("{}?client_id={}", &config.server, publish_client_id);
31+
let mut options = MqttOptions::parse_url(&mqtt_url).unwrap();
32+
if matches!(password, Some(_)) && matches!(username, Some(_)) {
33+
options.set_credentials(username.unwrap(), password.unwrap());
34+
}
2935
let (client, mut eventloop) = AsyncClient::new(options,20);
3036

3137
let topic = config.get_response_command_topic();

agent/src/config.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct Config {
1414
pub client_id: String,
1515
pub username: Option<String>,
1616
pub password: Option<String>,
17+
1718
}
1819

1920
impl Config {
@@ -40,11 +41,11 @@ impl Config {
4041
}
4142

4243
pub fn get_command_topic(&self) -> String {
43-
self.command_topic.clone().unwrap_or_else(||format!("{}/cmd", self.client_id))
44+
self.command_topic.clone().unwrap_or_else(||format!("cmd/{}", self.client_id))
4445

4546
}
4647
pub fn get_response_command_topic(&self) -> String {
47-
self.command_topic.clone().unwrap_or_else(||format!("{}/cmd/resp", self.client_id))
48+
self.command_topic.clone().unwrap_or_else(||format!("cmd/{}/resp", self.client_id))
4849
}
4950
}
5051

shell/prod/rmqtt/rmqtt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ node.busy.handshaking = 0
5858
# Value: off | file | console | both
5959
log.to = "file"
6060
# Value: trace, debug, info, warn, error
61-
log.level = "debug"
61+
log.level = "info"
6262
log.dir = "/var/log/rmqtt"
6363
log.file = "rmqtt.log"
6464

0 commit comments

Comments
 (0)