mirror of
https://github.com/apple/container.git
synced 2026-07-12 20:47:04 +00:00
- Forgot to commit the changes to gracefully shut down the event loop group used by the port forwards.
This commit is contained in:
@@ -25,6 +25,7 @@ import Containerization
|
||||
import ContainerizationError
|
||||
import Foundation
|
||||
import Logging
|
||||
import NIO
|
||||
|
||||
@main
|
||||
struct RuntimeLinuxHelper: AsyncParsableCommand {
|
||||
@@ -57,6 +58,7 @@ struct RuntimeLinuxHelper: AsyncParsableCommand {
|
||||
log.info("stopping \(commandName)")
|
||||
}
|
||||
|
||||
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
|
||||
do {
|
||||
try adjustLimits()
|
||||
signal(SIGPIPE, SIG_IGN)
|
||||
@@ -68,7 +70,7 @@ struct RuntimeLinuxHelper: AsyncParsableCommand {
|
||||
} else {
|
||||
interfaceStrategy = IsolatedInterfaceStrategy()
|
||||
}
|
||||
let server = SandboxService(root: .init(fileURLWithPath: root), interfaceStrategy: interfaceStrategy, log: log)
|
||||
let server = SandboxService(root: .init(fileURLWithPath: root), interfaceStrategy: interfaceStrategy, eventLoopGroup: eventLoopGroup, log: log)
|
||||
let xpc = XPCServer(
|
||||
identifier: machServiceLabel,
|
||||
routes: [
|
||||
@@ -89,6 +91,7 @@ struct RuntimeLinuxHelper: AsyncParsableCommand {
|
||||
try await xpc.listen()
|
||||
} catch {
|
||||
log.error("\(commandName) failed", metadata: ["error": "\(error)"])
|
||||
try? await eventLoopGroup.shutdownGracefully()
|
||||
RuntimeLinuxHelper.exit(withError: error)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public actor SandboxService {
|
||||
private let interfaceStrategy: InterfaceStrategy
|
||||
private var container: ContainerInfo?
|
||||
private let monitor: ExitMonitor
|
||||
private let eventLoopGroup: MultiThreadedEventLoopGroup
|
||||
private let eventLoopGroup: any EventLoopGroup
|
||||
private var waiters: [String: [CheckedContinuation<Int32, Never>]] = [:]
|
||||
private let lock: AsyncLock = AsyncLock()
|
||||
private let log: Logging.Logger
|
||||
@@ -54,12 +54,12 @@ public actor SandboxService {
|
||||
/// - interfaceStrategy: The strategy for producing network interface
|
||||
/// objects for each network to which the container attaches.
|
||||
/// - log: The destination for log messages.
|
||||
public init(root: URL, interfaceStrategy: InterfaceStrategy, log: Logger) {
|
||||
public init(root: URL, interfaceStrategy: InterfaceStrategy, eventLoopGroup: any EventLoopGroup, log: Logger) {
|
||||
self.root = root
|
||||
self.interfaceStrategy = interfaceStrategy
|
||||
self.log = log
|
||||
self.monitor = ExitMonitor(log: log)
|
||||
self.eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
|
||||
self.eventLoopGroup = eventLoopGroup
|
||||
}
|
||||
|
||||
/// Start the VM and the guest agent process for a container.
|
||||
|
||||
Reference in New Issue
Block a user