Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Sources/Helpers/RuntimeLinux/RuntimeLinuxHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Containerization
import ContainerizationError
import Foundation
import Logging
import NIO

@main
struct RuntimeLinuxHelper: AsyncParsableCommand {
Expand Down Expand Up @@ -57,6 +58,7 @@ struct RuntimeLinuxHelper: AsyncParsableCommand {
log.info("stopping \(commandName)")
}

let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
do {
try adjustLimits()
signal(SIGPIPE, SIG_IGN)
Expand All @@ -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: [
Expand All @@ -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)
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Services/ContainerSandboxService/SandboxService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down