Skip to content

Commit ebc5101

Browse files
committed
wip for web devlop
1 parent eeaba5d commit ebc5101

File tree

12 files changed

+1027
-94
lines changed

12 files changed

+1027
-94
lines changed

agent/src/config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use anyhow::bail;
22
use etcetera::BaseStrategy;
33
use serde::{Deserialize, Serialize};
44
use std::path::PathBuf;
5+
use tracing::info;
56

67
pub const APP_NAME: &str = "mproxy";
78

@@ -21,7 +22,7 @@ impl Config {
2122
if !config_path.is_file() {
2223
bail!("config file not found: {:?}", config_path);
2324
}
24-
25+
info!("load config from {:?}", config_path);
2526
let config = std::fs::read_to_string(config_path)?;
2627
let config: Config = serde_yml::from_str(&config)?;
2728
Ok(config)

agent/src/connection.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use anyhow::{bail, Context};
44
use rumqttc::v5::{MqttOptions, AsyncClient, EventLoop, Event, Incoming, ClientError};
55
use rumqttc::v5::mqttbytes::QoS;
66
use tokio::sync::broadcast;
7-
use tracing::{debug, error, warn};
7+
use tracing::{debug, error, info, warn};
88

99
use crate::config::Config;
1010
use crate::handler::{RequestMessage, ResponseMessage};
@@ -17,6 +17,7 @@ pub struct Connection {
1717

1818
impl Connection {
1919
pub async fn connect(config:Arc<Config>) -> anyhow::Result<(Self, EventLoop)>{
20+
info!("begin to connect mqtt server: {}", &config.server);
2021
let mqtt_url = format!("{}?client_id={}", &config.server, &config.client_id);
2122
let mut options = MqttOptions::parse_url(&mqtt_url).with_context(|| format!("parser mqtt url fail: {:?}", &mqtt_url))?;
2223

@@ -31,6 +32,7 @@ impl Connection {
3132
let (client, eventloop) = AsyncClient::new(options, 20);
3233
let topic = config.get_command_topic();
3334
let _ = client.subscribe(topic, QoS::ExactlyOnce).await?;
35+
info!("connect mqtt server successful");
3436
Ok((Connection {
3537
client,
3638
}, eventloop))

0 commit comments

Comments
 (0)