@@ -19,17 +19,19 @@ impl RunningServices {
1919 ///
2020 /// ```text
2121 /// Loading configuration from default configuration file: `./share/default/config/tracker.development.sqlite3.toml` ...
22- /// 2024-06-10T14:59:57.973525Z INFO torrust_tracker::bootstrap::logging: logging initialized.
23- /// 2024-06-10T14:59:57.974306Z INFO UDP TRACKER: Starting on: udp://0.0.0.0:6969
24- /// 2024-06-10T14:59:57.974316Z INFO UDP TRACKER: Started on: udp://0.0.0.0:6969
25- /// 2024-06-10T14:59:57.974332Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
26- /// 2024-06-10T14:59:57.974366Z INFO HTTP TRACKER: Starting on: http://0.0.0.0:7070
27- /// 2024-06-10T14:59:57.974513Z INFO HTTP TRACKER: Started on: http://0.0.0.0:7070
28- /// 2024-06-10T14:59:57.974521Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
29- /// 2024-06-10T14:59:57.974615Z INFO API: Starting on http://127.0.0.1:1212
30- /// 2024-06-10T14:59:57.974618Z INFO API: Started on http://127.0.0.1:1212
31- /// 2024-06-10T14:59:57.974643Z INFO HEALTH CHECK API: Starting on: http://127.0.0.1:1313
32- /// 2024-06-10T14:59:57.974760Z INFO HEALTH CHECK API: Started on: http://127.0.0.1:1313
22+ /// 2024-06-10T16:07:39.989540Z INFO torrust_tracker::bootstrap::logging: logging initialized.
23+ /// 2024-06-10T16:07:39.990205Z INFO UDP TRACKER: Starting on: udp://0.0.0.0:6868
24+ /// 2024-06-10T16:07:39.990215Z INFO UDP TRACKER: Started on: udp://0.0.0.0:6868
25+ /// 2024-06-10T16:07:39.990244Z INFO UDP TRACKER: Starting on: udp://0.0.0.0:6969
26+ /// 2024-06-10T16:07:39.990255Z INFO UDP TRACKER: Started on: udp://0.0.0.0:6969
27+ /// 2024-06-10T16:07:39.990261Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
28+ /// 2024-06-10T16:07:39.990303Z INFO HTTP TRACKER: Starting on: http://0.0.0.0:7070
29+ /// 2024-06-10T16:07:39.990439Z INFO HTTP TRACKER: Started on: http://0.0.0.0:7070
30+ /// 2024-06-10T16:07:39.990448Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
31+ /// 2024-06-10T16:07:39.990563Z INFO API: Starting on http://127.0.0.1:1212
32+ /// 2024-06-10T16:07:39.990565Z INFO API: Started on http://127.0.0.1:1212
33+ /// 2024-06-10T16:07:39.990577Z INFO HEALTH CHECK API: Starting on: http://127.0.0.1:1313
34+ /// 2024-06-10T16:07:39.990638Z INFO HEALTH CHECK API: Started on: http://127.0.0.1:1313
3335 /// ```
3436 ///
3537 /// It would extract these services:
@@ -48,7 +50,7 @@ impl RunningServices {
4850 /// }
4951 /// ```
5052 ///
51- /// NOTICE: Using colors in the console output could affect this method
53+ /// NOTICE: Using colors in the console output could affect this method
5254 /// due to the hidden control chars.
5355 #[ must_use]
5456 pub fn parse_from_logs ( logs : & str ) -> Self {
@@ -89,7 +91,7 @@ mod tests {
8991
9092 #[ test]
9193 fn it_should_parse_from_logs_with_valid_logs ( ) {
92- let log = r#"
94+ let logs = r#"
9395 Loading configuration from environment variable db_path = "/var/lib/torrust/tracker/database/sqlite3.db"
9496
9597 [[udp_trackers]]
@@ -103,22 +105,22 @@ mod tests {
103105 [http_api]
104106 ssl_cert_path = "/var/lib/torrust/tracker/tls/localhost.crt"
105107 ssl_key_path = "/var/lib/torrust/tracker/tls/localhost.key"
106- ...
107- Loading configuration from file: `/etc/torrust/tracker /tracker.toml` ...
108- 2024-06-10T15:09:54.411031Z INFO torrust_tracker::bootstrap::logging: logging initialized.
109- 2024-06-10T15:09:54.415084Z INFO UDP TRACKER: Starting on: udp://0.0.0.0:6969
110- 2024-06-10T15:09:54.415091Z INFO UDP TRACKER: Started on: udp://0.0.0.0:6969
111- 2024-06-10T15:09:54.415104Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
112- 2024-06-10T15:09:54.415130Z INFO HTTP TRACKER: Starting on: http://0.0.0.0:7070
113- 2024-06-10T15:09:54.415266Z INFO HTTP TRACKER: Started on: http://0.0.0.0:7070
114- 2024-06-10T15:09:54.415275Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
115- 2024-06-10T15:09:54.415403Z INFO API: Starting on http://127.0.0.1:1212
116- 2024-06-10T15:09:54.415411Z INFO API: Started on http://127.0.0.1:1212
117- 2024-06-10T15:09:54.415430Z INFO HEALTH CHECK API: Starting on: http://127.0.0.1:1313
118- 2024-06-10T15:09:54.415472Z INFO HEALTH CHECK API: Started on: http://127.0.0.1:1313
108+
109+ Loading configuration from default configuration file: `./share/default/config /tracker.development.sqlite3 .toml` ...
110+ 2024-06-10T16:07:39.989540Z INFO torrust_tracker::bootstrap::logging: logging initialized.
111+ 2024-06-10T16:07:39.990244Z INFO UDP TRACKER: Starting on: udp://0.0.0.0:6969
112+ 2024-06-10T16:07:39.990255Z INFO UDP TRACKER: Started on: udp://0.0.0.0:6969
113+ 2024-06-10T16:07:39.990261Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
114+ 2024-06-10T16:07:39.990303Z INFO HTTP TRACKER: Starting on: http://0.0.0.0:7070
115+ 2024-06-10T16:07:39.990439Z INFO HTTP TRACKER: Started on: http://0.0.0.0:7070
116+ 2024-06-10T16:07:39.990448Z INFO torrust_tracker::bootstrap::jobs: TLS not enabled
117+ 2024-06-10T16:07:39.990563Z INFO API: Starting on http://127.0.0.1:1212
118+ 2024-06-10T16:07:39.990565Z INFO API: Started on http://127.0.0.1:1212
119+ 2024-06-10T16:07:39.990577Z INFO HEALTH CHECK API: Starting on: http://127.0.0.1:1313
120+ 2024-06-10T16:07:39.990638Z INFO HEALTH CHECK API: Started on: http://127.0.0.1:1313
119121 "# ;
120122
121- let running_services = RunningServices :: parse_from_logs ( log ) ;
123+ let running_services = RunningServices :: parse_from_logs ( logs ) ;
122124
123125 assert_eq ! ( running_services. udp_trackers, vec![ "127.0.0.1:6969" ] ) ;
124126 assert_eq ! ( running_services. http_trackers, vec![ "http://127.0.0.1:7070" ] ) ;
@@ -128,13 +130,29 @@ mod tests {
128130 #[ test]
129131 fn it_should_ignore_logs_with_no_matching_lines ( ) {
130132 let logs = "[Other Service][INFO] Started on: 0.0.0.0:7070" ;
133+
131134 let running_services = RunningServices :: parse_from_logs ( logs) ;
132135
133136 assert ! ( running_services. udp_trackers. is_empty( ) ) ;
134137 assert ! ( running_services. http_trackers. is_empty( ) ) ;
135138 assert ! ( running_services. health_checks. is_empty( ) ) ;
136139 }
137140
141+ #[ test]
142+ fn it_should_parse_multiple_services ( ) {
143+ let logs = "
144+ 2024-06-10T16:07:39.990205Z INFO UDP TRACKER: Starting on: udp://0.0.0.0:6868
145+ 2024-06-10T16:07:39.990215Z INFO UDP TRACKER: Started on: udp://0.0.0.0:6868
146+
147+ 2024-06-10T16:07:39.990244Z INFO UDP TRACKER: Starting on: udp://0.0.0.0:6969
148+ 2024-06-10T16:07:39.990255Z INFO UDP TRACKER: Started on: udp://0.0.0.0:6969
149+ " ;
150+
151+ let running_services = RunningServices :: parse_from_logs ( logs) ;
152+
153+ assert_eq ! ( running_services. udp_trackers, vec![ "127.0.0.1:6868" , "127.0.0.1:6969" ] ) ;
154+ }
155+
138156 #[ test]
139157 fn it_should_replace_wildcard_ip_with_localhost ( ) {
140158 let address = "0.0.0.0:8080" ;
0 commit comments