public CommandRunner(ServiceManager svc, ExtensionClientManager extmgr) { _svc = svc; _extmgr = extmgr; Add(ExecCommand.Get()); Add(RestartCommand.Get()); }
public ServiceManager() { ServiceManagerNotificationTarget.ServiceManager = this; _logger = LogManager.GetCurrentClassLogger(); ExtensionNotificationReceived += (procID, extID, extName, level, source, message) => CallbackEachClient <IServiceManagerCallback>(c => c.ServerExtensionNotify(procID, extID, extName, level, source, message)); ServiceManagerNotificationReceived += (level, source, message) => CallbackEachClient <IServiceManagerCallback>(c => c.Notify(level, source, message)); _extensionsBaseDir = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Extensions")); if (!_extensionsBaseDir.Exists) { _extensionsBaseDir.Create(); } if (_extensionsBaseDir.GetFiles().Select(f => f.Extension.ToLower()).Any(ext => _extensionFileExtensions.Contains(ext))) { throw new Exception("The extensions directory currently contains assemblies and/or executables. Extensions should be located in subdirectories of the Extensions folder; not the Extensions directory itself."); } _extProcMgr = new ExtensionProcessManager( Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ServerX.Run.exe"), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Extensions") ); _extClientMgr = new ExtensionClientManager(_extProcMgr); _extClientMgr.ExtensionNotificationReceived += (procID, extID, extName, level, source, message) => { NotificationLogBuffer.Add(procID, _extProcMgr.GetExtensionDirectoryName(procID), extID, extName, level, source, message); var handler = ExtensionNotificationReceived; if (handler != null) { handler(procID, extID, extName, level, source, message); } }; _extProcMgr.StartMonitoring(); _extCfgMgr = new ExtensionsConfigFileManager(_extProcMgr); Task.Factory.StartNew(() => _extCfgMgr.Init()); _cmdRunner = new CommandRunner(this, _extClientMgr); _cronMgr = new CronManager(this); }
public ScriptRunner(ServiceManager svc, ExtensionClientManager clientManager) { _svc = svc; _clientManager = clientManager; _engine.DisableSecurity(); _engine.SetFunction("__svc_jsonCall", new Func<string, string, string>(ServiceManagerJsonCall)); _engine.SetFunction("__ext_jsonCall", new Func<string, string, string, string>(ExtensionJsonCall)); _preScript = string.Concat( Resources.json2, Resources.scriptrunner, JavaScriptInterface.GenerateJavaScriptWrapper(svc), clientManager.GetJavaScriptWrappers() ); try { _engine.Run(_preScript); } catch(Exception ex) { LastException = ex; } }
public ScriptRunner(ServiceManager svc, ExtensionClientManager clientManager) { _svc = svc; _clientManager = clientManager; _engine.DisableSecurity(); _engine.SetFunction("__svc_jsonCall", new Func <string, string, string>(ServiceManagerJsonCall)); _engine.SetFunction("__ext_jsonCall", new Func <string, string, string, string>(ExtensionJsonCall)); _preScript = string.Concat( Resources.json2, Resources.scriptrunner, JavaScriptInterface.GenerateJavaScriptWrapper(svc), clientManager.GetJavaScriptWrappers() ); try { _engine.Run(_preScript); } catch (Exception ex) { LastException = ex; } }
public ServiceManager() { ServiceManagerNotificationTarget.ServiceManager = this; _logger = LogManager.GetCurrentClassLogger(); ExtensionNotificationReceived += (procID, extID, extName, level, source, message) => CallbackEachClient<IServiceManagerCallback>(c => c.ServerExtensionNotify(procID, extID, extName, level, source, message)); ServiceManagerNotificationReceived += (level, source, message) => CallbackEachClient<IServiceManagerCallback>(c => c.Notify(level, source, message)); _extensionsBaseDir = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Extensions")); if(!_extensionsBaseDir.Exists) _extensionsBaseDir.Create(); if(_extensionsBaseDir.GetFiles().Select(f => f.Extension.ToLower()).Any(ext => _extensionFileExtensions.Contains(ext))) throw new Exception("The extensions directory currently contains assemblies and/or executables. Extensions should be located in subdirectories of the Extensions folder; not the Extensions directory itself."); _extProcMgr = new ExtensionProcessManager( Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ServerX.Run.exe"), Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Extensions") ); _extClientMgr = new ExtensionClientManager(_extProcMgr); _extClientMgr.ExtensionNotificationReceived += (procID, extID, extName, level, source, message) => { NotificationLogBuffer.Add(procID, _extProcMgr.GetExtensionDirectoryName(procID), extID, extName, level, source, message); var handler = ExtensionNotificationReceived; if(handler != null) handler(procID, extID, extName, level, source, message); }; _extProcMgr.StartMonitoring(); _extCfgMgr = new ExtensionsConfigFileManager(_extProcMgr); Task.Factory.StartNew(() => _extCfgMgr.Init()); _cmdRunner = new CommandRunner(this, _extClientMgr); _cronMgr = new CronManager(this); }