Changeset 1a00f73
- Timestamp:
- Oct 12, 2018 8:52:24 PM (2 years ago)
- Branches:
- master
- Children:
- 5f07789
- Parents:
- d8cfe21e
- Location:
- launchers/macosx/I2PLauncher/Utils
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
launchers/macosx/I2PLauncher/Utils/LaunchAgent+Status.swift
rd8cfe21e r1a00f73 35 35 /// 36 36 /// Check the status of the job with `.status()` 37 public func start( ) {38 LaunchAgentManager.shared.start(self )37 public func start(_ callback: ((Process) -> Void)? = nil ) { 38 LaunchAgentManager.shared.start(self, callback) 39 39 } 40 40 … … 42 42 /// 43 43 /// Check the status of the job with `.status()` 44 public func stop( ) {45 LaunchAgentManager.shared.stop(self )44 public func stop(_ callback: ((Process) -> Void)? = nil ) { 45 LaunchAgentManager.shared.stop(self, callback) 46 46 } 47 47 -
launchers/macosx/I2PLauncher/Utils/LaunchAgentManager.swift
rd8cfe21e r1a00f73 89 89 /// 90 90 /// Check the status of the job with `.status(_: LaunchAgent)` 91 public func start(_ agent: LaunchAgent ) {91 public func start(_ agent: LaunchAgent, _ termHandler: ((Process) -> Void)? = nil ) { 92 92 let arguments = ["start", agent.label] 93 Process.launchedProcess(launchPath: LaunchAgentManager.launchctl, arguments: arguments) 93 let proc = Process.launchedProcess(launchPath: LaunchAgentManager.launchctl, arguments: arguments) 94 if ((termHandler) != nil) { 95 proc.terminationHandler = termHandler 96 } 94 97 } 95 98 … … 97 100 /// 98 101 /// Check the status of the job with `.status(_: LaunchAgent)` 99 public func stop(_ agent: LaunchAgent ) {102 public func stop(_ agent: LaunchAgent, _ termHandler: ((Process) -> Void)? = nil ) { 100 103 let arguments = ["stop", agent.label] 101 Process.launchedProcess(launchPath: LaunchAgentManager.launchctl, arguments: arguments) 104 let proc = Process.launchedProcess(launchPath: LaunchAgentManager.launchctl, arguments: arguments) 105 if ((termHandler) != nil) { 106 proc.terminationHandler = termHandler 107 } 102 108 } 103 109 … … 105 111 /// 106 112 /// Check the status of the job with `.status(_: LaunchAgent)` 107 public func load(_ agent: LaunchAgent ) throws {113 public func load(_ agent: LaunchAgent, _ termHandler: ((Process) -> Void)? = nil ) throws { 108 114 guard let agentURL = agent.url else { 109 115 throw LaunchAgentManagerError.urlNotSet(label: agent.label) … … 111 117 112 118 let arguments = ["load", agentURL.path] 113 Process.launchedProcess(launchPath: LaunchAgentManager.launchctl, arguments: arguments) 119 let proc = Process.launchedProcess(launchPath: LaunchAgentManager.launchctl, arguments: arguments) 120 if ((termHandler) != nil) { 121 proc.terminationHandler = termHandler 122 } 114 123 } 115 124 … … 117 126 /// 118 127 /// Check the status of the job with `.status(_: LaunchAgent)` 119 public func unload(_ agent: LaunchAgent ) throws {128 public func unload(_ agent: LaunchAgent, _ termHandler: ((Process) -> Void)? = nil ) throws { 120 129 guard let agentURL = agent.url else { 121 130 throw LaunchAgentManagerError.urlNotSet(label: agent.label) … … 123 132 124 133 let arguments = ["unload", agentURL.path] 125 Process.launchedProcess(launchPath: LaunchAgentManager.launchctl, arguments: arguments) 134 let proc = Process.launchedProcess(launchPath: LaunchAgentManager.launchctl, arguments: arguments) 135 if ((termHandler) != nil) { 136 proc.terminationHandler = termHandler 137 } 126 138 } 127 139
Note: See TracChangeset
for help on using the changeset viewer.