diff --git a/modules/message-box.js b/modules/message-box.js index 098b997..048bf44 100644 --- a/modules/message-box.js +++ b/modules/message-box.js @@ -208,6 +208,21 @@ function linux_messageBox() }; } +function macos_messageBox() +{ + this._ObjectID = 'message-box'; + this.create = function create(title, caption, timeout) + { + }; + this.notify = function notify(title, caption) + { + }; + this.startServer = function startServer(options) + { + }; +} + + switch(process.platform) { case 'win32': @@ -215,6 +230,9 @@ switch(process.platform) break; case 'linux': module.exports = new linux_messageBox(); + break; + case 'darwin': + break; } diff --git a/modules/service-manager.js b/modules/service-manager.js index 6ee6b30..dc0685f 100644 --- a/modules/service-manager.js +++ b/modules/service-manager.js @@ -1060,6 +1060,72 @@ function serviceManager() } } } + if (process.platform == 'darwin') + { + this.installLaunchAgent = function installLaunchAgent(options) + { + if (!this.isAdmin()) { throw ('Installing a service, requires admin'); } + var servicePathTokens = options.servicePath.split('/'); + servicePathTokens.pop(); + if (servicePathTokens.peek() == '.') { servicePathTokens.pop(); } + options.workingDirectory = servicePathTokens.join('/'); + + var autoStart = (options.startType == 'AUTO_START' ? '' : ''); + var stdoutpath = (options.stdout ? ('StandardOutPath\n' + options.stdout + '') : ''); + var params = ' ProgramArguments\n'; + params += ' \n'; + params += (' ' + options.servicePath + '\n'); + if (options.parameters) { + for (var itm in options.parameters) + { + params += (' ' + options.parameters[itm] + '\n'); + } + } + params += ' \n'; + + var plist = '\n'; + plist += '\n'; + plist += '\n'; + plist += ' \n'; + plist += ' Label\n'; + plist += (' ' + options.name + '\n'); + plist += (params + '\n'); + plist += ' WorkingDirectory\n'; + plist += (' ' + options.workingDirectory + '\n'); + plist += (stdoutpath + '\n'); + plist += ' RunAtLoad\n'; + plist += (autoStart + '\n'); + if (options.sessionTypes && options.sessionTypes.length > 0) + { + plist += ' LimitLoadToSessionType\n'; + plist += ' \n'; + for (var stype in options.sessionTypes) + { + plist += (' ' + options.sessionTypes[stype] + '\n'); + } + plist += ' \n'; + } + plist += ' KeepAlive\n'; + if (options.failureRestart == null || options.failureRestart > 0) { + plist += ' \n'; + plist += ' Crashed\n'; + plist += ' \n'; + plist += ' \n'; + } + else { + plist += ' \n'; + } + if (options.failureRestart != null) { + plist += ' ThrottleInterval\n'; + plist += ' ' + (options.failureRestart / 1000) + '\n'; + } + + plist += ' \n'; + plist += ''; + + require('fs').writeFileSync('/Library/LaunchAgents/' + options.name + '.plist', plist); + }; + } this.uninstallService = function uninstallService(name) { if (!this.isAdmin()) { throw ('Uninstalling a service, requires admin'); }