File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ import GRPCCore
2626import Logging
2727import NIOCore
2828import NIOPosix
29- import Synchronization
3029
3130#if os(Linux)
3231#if canImport(Musl)
@@ -46,8 +45,6 @@ public struct AgentCommand: AsyncParsableCommand {
4645 private static let foregroundEnvVar = " FOREGROUND "
4746 public static let vsockPort = 1024
4847
49- public static let versionMetadata = Mutex < Logger . Metadata > ( [ : ] )
50-
5148 @OptionGroup var options : LogLevelOption
5249
5350 public init ( ) { }
@@ -81,7 +78,7 @@ public struct AgentCommand: AsyncParsableCommand {
8178
8279 signal ( SIGPIPE, SIG_IGN)
8380
84- log. info ( " vminitd booting " , metadata: Self . versionMetadata. withLock { $0 } )
81+ log. info ( " vminitd booting " , metadata: versionMetadata ( ) )
8582
8683 // Set of mounts necessary to be mounted prior to taking any RPCs.
8784 // 1. /proc as the sysctl rpc wouldn't make sense if it wasn't there (NOTE: This is done before this method
Original file line number Diff line number Diff line change @@ -50,6 +50,16 @@ public struct LogLevelOption: ParsableArguments {
5050}
5151
5252private let _loggingBootstrapped = Mutex ( false )
53+ private let _versionMetadata = Mutex < Logger . Metadata > ( [ : ] )
54+
55+ /// Set the version metadata logged on boot.
56+ public func setVersionMetadata( _ metadata: Logger . Metadata ) {
57+ _versionMetadata. withLock { $0 = metadata }
58+ }
59+
60+ func versionMetadata( ) -> Logger . Metadata {
61+ _versionMetadata. withLock { $0 }
62+ }
5363
5464func makeLogger( label: String , level: Logger . Level ) -> Logger {
5565 _loggingBootstrapped. withLock { bootstrapped in
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ struct Application: AsyncParsableCommand {
3636 )
3737
3838 static func main( ) async throws {
39- AgentCommand . versionMetadata . withLock { $0 = Self . versionMetadata ( ) }
39+ setVersionMetadata ( Self . versionMetadata ( ) )
4040
4141 // Busybox-style: if invoked as .cz-init, run init mode directly.
4242 let invoked = CommandLine . arguments. first? . split ( separator: " / " ) . last. map ( String . init) ?? " "
You can’t perform that action at this time.
0 commit comments