File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -345,6 +345,13 @@ async fn serve_with_csa(
345
345
log = log. tee ( log_broadcast. clone ( ) ) ;
346
346
log:: install_global_logger ( log. clone ( ) ) ; // re-install so that library logs are captured
347
347
348
+ debug ! (
349
+ log,
350
+ "Starting tunnel with `{} {}`" ,
351
+ APPLICATION_NAME ,
352
+ std:: env:: args( ) . collect:: <Vec <_>>( ) . join( " " )
353
+ ) ;
354
+
348
355
// Intentionally read before starting the server. If the server updated and
349
356
// respawn is requested, the old binary will get renamed, and then
350
357
// current_exe will point to the wrong path.
@@ -435,7 +442,10 @@ async fn serve_with_csa(
435
442
436
443
return Ok ( exit. code ( ) . unwrap_or ( 1 ) ) ;
437
444
}
438
- Next :: Exit => return Ok ( 0 ) ,
445
+ Next :: Exit => {
446
+ debug ! ( log, "Tunnel shut down" ) ;
447
+ return Ok ( 0 ) ;
448
+ }
439
449
Next :: Restart => continue ,
440
450
}
441
451
}
Original file line number Diff line number Diff line change @@ -159,9 +159,21 @@ pub struct FileLogSink {
159
159
file : Arc < std:: sync:: Mutex < std:: fs:: File > > ,
160
160
}
161
161
162
+ const FILE_LOG_SIZE_LIMIT : u64 = 1024 * 1024 * 10 ; // 10MB
163
+
162
164
impl FileLogSink {
163
165
pub fn new ( level : Level , path : & Path ) -> std:: io:: Result < Self > {
164
- let file = std:: fs:: File :: create ( path) ?;
166
+ // Truncate the service log occasionally to avoid growing infinitely
167
+ if matches ! ( path. metadata( ) , Ok ( m) if m. len( ) > FILE_LOG_SIZE_LIMIT ) {
168
+ // ignore errors, can happen if another process is writing right now
169
+ let _ = std:: fs:: remove_file ( path) ;
170
+ }
171
+
172
+ let file = std:: fs:: OpenOptions :: new ( )
173
+ . append ( true )
174
+ . create ( true )
175
+ . open ( path) ?;
176
+
165
177
Ok ( Self {
166
178
level,
167
179
file : Arc :: new ( std:: sync:: Mutex :: new ( file) ) ,
You can’t perform that action at this time.
0 commit comments