Start() 공개 메소드

public Start ( ) : void
리턴 void
예제 #1
0
        public static async Task StartMonitoringAsync()
        {
            var monitoringUrl      = Environment.GetEnvironmentVariable("monitoring_url");
            var monitoringInterval = Environment.GetEnvironmentVariable("monitoring_interval") ?? "30000";

            if (monitoringUrl != null)
            {
                var monitor = new Monitor(new Models.MonitorConfig()
                {
                    Url = monitoringUrl, Interval = int.Parse(monitoringInterval), Method = Models.MonitorConfig.AvailableMethods.GET
                }, "");
                monitor.Start();
            }

            Monitors = new List <Monitor>();
            //search for all users monitoring tasks
            var usersConfigs = await Extensions.MongoDB.FromMongoDB <Models.UserMonitorConfig>();

            if (usersConfigs != null)
            {
                usersConfigs.ToList().ForEach(user =>
                {
                    Console.WriteLine($"Loading '{user.Data.Count()}' monitors of user '{user.uid}'");
                    Monitors.AddRange(user.Data.Select(config => new Monitor(config, user.uid)).ToList());
                    Monitors.ForEach(m => m.Config.Id = user._id.oid); //add mongodb id
                    Monitors.ForEach(m => m.Start());
                });
            }
        }
예제 #2
0
        private async static Task <int> MonitorJob(MonitorOptions opts)
        {
            Monitor orchestrator = new Monitor(opts);
            await orchestrator.Start().ConfigureAwait(true);

            return(0);
        }
예제 #3
0
        private static void Main(string[] args)
        {
            //string filename =
            //    @"..\..\..\Dev.ProcessMonitor.TestTargerExe\bin\Debug\Dev.ProcessMonitor.TestTargerExe.exe";
            //string arg = "";


            ////string filename =
            ////   @"..\..\..\Dev.ProcessMonitor.FormTest\bin\Debug\Dev.ProcessMonitor.FormTest.exe";
            ////string arg = "";

            //var starter = new ProcessStarterAsyn(filename, arg);
            //starter.StandardErrorOut += starter_StandardErrorOut;
            //starter.StandardOut += starter_StandardOut;
            //starter.StartAsyn();


            //Console.WriteLine("pressanykey");


            var m = new Monitor(true);
            m.StandardErrorOut += m_StandardErrorOut;
            m.Start();

            Console.ReadKey();


            m.Stop();
        }
예제 #4
0
        private Task StartTransport()
        {
            return(_transport.Start(this, _connectionData, _disconnectCts.Token)
                   .RunSynchronously(() =>
            {
                lock (_stateLock)
                {
                    // NOTE: We have tests that rely on this state change occuring *BEFORE* the start task is complete
                    if (!ChangeState(ConnectionState.Connecting, ConnectionState.Connected))
                    {
                        throw new StartException(Resources.Error_ConnectionCancelled, LastError);
                    }

                    // Now that we're connected complete the start task that the
                    // receive queue is waiting on
                    _startTcs.TrySetResult(null);

                    // Start the monitor to check for server activity
                    _lastMessageAt = DateTime.UtcNow;
                    _lastActiveAt = DateTime.UtcNow;
                    Monitor.Start();
                }
            })
                   // Don't return until the last receive has been processed to ensure messages/state sent in OnConnected
                   // are processed prior to the Start() method task finishing
                   .Then(() => _lastQueuedReceiveTask));
        }
예제 #5
0
        private async Task UpdateUserState(UserState userState, bool raiseEvent, bool updateStore)
        {
            UserState = userState;

            if (UserState == null)
            {
                SessionIsValid = false;
                if (Settings.MonitorSession)
                {
                    Monitor.Stop();
                }
                if (updateStore)
                {
                    await Helper.ClearUserState();
                }
            }
            else
            {
                SessionIsValid = true;
                if (Settings.MonitorSession)
                {
                    await Monitor.Start(UserState);
                }
                if (updateStore)
                {
                    await Helper.SetUserState(userState);
                }
            }

            if (raiseEvent)
            {
                UserChanged?.Invoke(userState?.User);
            }
        }
예제 #6
0
 protected override void OnStart(string[] args)
 {
     m = new Monitor(true);
     m.StandardErrorOut += m_StandardErrorOut;
     m.StandardOut += m_StandardOut;
     m.Start();
 }
예제 #7
0
        private async Task UpdateUserState(UserState userState, bool raiseEvent, bool updateStore)
        {
            UserState = userState;

            if (UserState == null)
            {
                SessionIsValid = false;
                Monitor.Stop();
                await Store.RemoveUserState();

                HttpClient.RemoveToken();
            }
            else
            {
                SessionIsValid = true;
                await Monitor.Start(UserState);

                await Store.SetUserState(userState);

                HttpClient.SetToken(UserState.AccessToken);
            }

            if (raiseEvent)
            {
                UserChanged?.Invoke(userState?.User);
            }
        }
예제 #8
0
        private void button4_Click(object sender, EventArgs e)
        {
            var m = new Monitor(true);

            m.StandardErrorOut += starter_StandardErrorOut;
            m.StandardOut += starter_StandardOut;
            m.Start();
        }
예제 #9
0
 static void Main(string[] args)
 {
     if (args.Length != 2)
     {
         Console.WriteLine("Failed to start monitor. 2 parameters required. Do not start monitor directly, use `course` tool");
     }
     Monitor.Start(args[0], args[1]);
 }
예제 #10
0
        protected virtual void JobExecuteScript(ClientPipelineArgs args, string scriptToExecute,
                                                ScriptSession scriptSession, bool autoDispose, bool debug)
        {
            ScriptRunning = true;
            UpdateRibbon();

            PowerShellLog.Info($"Arbitrary script execution in ISE by user: '******'");

            scriptSession.SetExecutedScript(ScriptItem);
            var parameters = new object[]
            {
                scriptSession,
                scriptToExecute
            };

            var progressBoxRunner = new ScriptRunner(ExecuteInternal, scriptSession, scriptToExecute, autoDispose);

            var rnd = new Random();

            Context.ClientPage.ClientResponse.SetInnerHtml(
                "ScriptResult",
                string.Format(
                    "<div id='PleaseWait'>" +
                    "<img src='../../../../../sitecore modules/PowerShell/Assets/working.gif' alt='" +
                    Texts.PowerShellIse_JobExecuteScript_Working +
                    "' />" +
                    "<div>" +
                    Texts.PowerShellIse_JobExecuteScript_Please_wait___0_ +
                    "</div>" +
                    "</div>" +
                    "<pre ID='ScriptResultCode'></pre>",
                    ExecutionMessages.PleaseWaitMessages[
                        rnd.Next(ExecutionMessages.PleaseWaitMessages.Length - 1)]));

            Context.ClientPage.ClientResponse.Eval("if(cognifide.powershell.preventCloseWhenRunning){cognifide.powershell.preventCloseWhenRunning(true);}");

            scriptSession.Debugging = debug;
            Monitor.Start($"{DefaultSessionName}", "ISE", progressBoxRunner.Run,
                          LanguageManager.IsValidLanguageName(CurrentLanguage)
                    ? LanguageManager.GetLanguage(CurrentLanguage)
                    : Context.Language,
                          User.Exists(CurrentUser)
                    ? User.FromName(CurrentUser, true)
                    : Context.User);

            Monitor.SessionID = scriptSession.ID;
            SheerResponse.Eval("cognifide.powershell.restoreResults();");

            var settings = ApplicationSettings.GetInstance(ApplicationNames.ISE);

            if (settings.SaveLastScript)
            {
                settings.Load();
                settings.LastScript = Editor.Value;
                settings.Save();
            }
        }
예제 #11
0
        private static void Main()
        {
            using (var monitor = new Monitor("c:\\foobar", "*.dll"))
            {
                monitor.Start();

                // breakpoints in your actual service should not be hit :)
            }
        }
예제 #12
0
        public void Bind(IPEndPoint ep)
        {
            if (Socket == null)
            {
                Socket = SocketManager.CreateUdp();
            }

            Monitor.Start();
            Socket.Bind(ep);
        }
예제 #13
0
        public void Bind(IPEndPoint ep)
        {
            if (socket == null)
            {
                socket   = SocketManager.CreateTcp(AddressFamily.InterNetwork);
                outQueue = new ConcurrentQueue <IPacket>();
                Monitor.Start();
            }

            socket.Bind(ep);
        }
예제 #14
0
        public virtual void Bind(IPEndPoint ep)
        {
            if (Socket == null)
            {
                Socket   = SocketManager.CreateTcp();
                outQueue = new ConcurrentQueue <IPacket>();
                Monitor.Start();
            }

            Socket.Bind(ep);
        }
예제 #15
0
        /// <summary>
        ///     Called when [start control].
        /// </summary>
        /// <param name="t">The t.</param>
        private void OnStartControl(TriggerArs t)
        {
            _inputGateway.Purge();

            _inputGateway.Start();
            if (Monitor != null)
            {
                Monitor.Start();
            }

            InvokeOnStart();
        }
예제 #16
0
        protected void OnJobStart(Message message)
        {
            var uri = ItemUri.ParseQueryString();

            if (uri != null)
            {
                var validator = new ItemValidator {
                    ItemUri = uri, Cookies = HttpContext.Current.Request.Cookies
                };
                Monitor.Start("Preview", "Crownpeak", new JobWorker(validator).GetPreview);
            }
        }
예제 #17
0
        protected void OnJobStart(Message message)
        {
            var uri = ItemUri.ParseQueryString();

            if (uri != null)
            {
                var checkpointId = HttpContext.Current.Request.QueryString["checkpointId"];
                var validator    = new ItemValidator {
                    ItemUri = uri, CheckpointId = checkpointId, Cookies = HttpContext.Current.Request.Cookies
                };
                Monitor.Start("Source", "Crownpeak", new JobWorker(validator).GetSource);
            }
        }
예제 #18
0
        public async Task <bool> UpdateMonitorAsync(string channel = null)
        {
            if (channel == null)
            {
                Monitor.Stop();
                MonitoredChannels.Clear();
                await SetCastersAsync();

                Monitor.Start();
                return(true);
            }
            else
            {
                try
                {
                    var user = await API.V5.Users.GetUserByNameAsync(channel);

                    string channelID = user.Matches[0].Id;

                    var ee = await API.V5.Streams.GetStreamByUserAsync(channelID);

                    if (_liveEmbeds.ContainsKey(channelID))
                    {
                        if (_client.ConnectionState == ConnectionState.Connected)
                        {
                            if (Setup.DiscordAnnounceChannel == 0)
                            {
                                return(false);
                            }
                            var msg = _liveEmbeds[channelID];

                            EmbedBuilder eb = SetupLiveEmbed($":link: {ee.Stream.Channel.DisplayName}", ee.Stream.Channel.Status, ee.Stream.Channel.Game,
                                                             ee.Stream.Preview.Medium + Guid.NewGuid().ToString(), ee.Stream.Channel.Logo, @"https://www.twitch.tv/" + ee.Stream.Channel.Name, ee.Stream.Viewers);

                            await msg.Item1.ModifyAsync(x => x.Embed = eb.Build());

                            _liveEmbeds[channelID] = new Tuple <RestUserMessage, string, string, int>(msg.Item1, ee.Stream.Channel.Status, ee.Stream.Channel.Game, ee.Stream.Viewers);

                            Console.WriteLine($"{Globals.CurrentTime} Monitor     Stream {ee.Stream.Channel.DisplayName} updated");
                            return(true);
                        }
                    }
                    return(false);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    return(false);
                }
            }
        }
예제 #19
0
        public void Execute()
        {
            var scriptSession = ScriptSessionManager.GetSession(PersistentId, Settings.ApplicationName, false);

            scriptSession.SetItemLocationContext(CurrentItem);
            scriptSession.SetExecutedScript(ScriptDb, ScriptId);
            scriptSession.SetVariable("Page", PageItem);
            scriptSession.SetVariable("RenderingId", RenderingId);
            scriptSession.Interactive = true;

            var runner = new ScriptRunner(ExecuteInternal, scriptSession, ScriptContent, string.IsNullOrEmpty(PersistentId));

            Monitor.Start("ScriptExecution", "PowerShellRunner", runner.Run, scriptSession.JobOptions);
            Monitor.SessionID = scriptSession.Key;
        }
예제 #20
0
        private void StartMonitor()
        {
            // start the monitor timer.
            // this is used to determine if we should be processing or not
            string _monitorStatusFileName       = ConfigurationManager.AppSettings["MonitorStatusFileName"];
            string _serverName                  = ConfigurationManager.AppSettings["ServiceName"];
            int    _serviceStartUpDelay         = Convert.ToInt32(ConfigurationManager.AppSettings["ServiceStartupDelay"]);
            int    _switchOverTimeout           = Convert.ToInt32(ConfigurationManager.AppSettings["SwitchOverTimeout"]);
            int    _monitorStatusUpdateInterval = Convert.ToInt32(ConfigurationManager.AppSettings["MonitorStatusUpdateInterval"]);

            // kick off the monitor timer.
            Trace.WriteLine("Starting Monitor");
            _monitor = new Monitor(_monitorStatusFileName, _serverName, _switchOverTimeout, _monitorStatusUpdateInterval);
            _monitor.Start();
        }
예제 #21
0
        public virtual void Connect(string host, int port)
        {
            disconnected = false;

            if (Socket == null)
            {
                Socket   = SocketManager.CreateTcp();
                outQueue = new ConcurrentQueue <IPacket>();
                Monitor.Start();
            }

            var task = new SocketConnectTask(host, port);

            task.Completed += ConnectCompleted;

            Socket.QueueConnect(task);
        }
예제 #22
0
        private static void MonitorChannels(IEnumerable <string> channelNames)
        {
            try
            {
                if (IsMonitoring)
                {
                    Monitor.Stop();
                }

                var channels = Links.ToList().Select(e => e.Value.Value.Split("|", StringSplitOptions.RemoveEmptyEntries).FirstOrDefault()).ToList();
                channels.AddRange(channelNames);
                Monitor.SetChannelsByName(channels.Distinct().ToList());
                Monitor.Start();
                IsMonitoring = true;
            }
            catch { }
        }
예제 #23
0
        public virtual void Listen(int backlog)
        {
            if (Socket == null)
            {
                Socket   = SocketManager.CreateTcp();
                outQueue = new ConcurrentQueue <IPacket>();
                Monitor.Start();
            }

            Socket.Listen(backlog);

            SocketAcceptTask task = new SocketAcceptTask();

            task.Completed += AcceptComplete;

            Socket.QueueAccept(task);
        }
예제 #24
0
        protected virtual void JobExecuteScript(ClientPipelineArgs args, string scriptToExecute,
                                                ScriptSession scriptSession, bool autoDispose, bool debug)
        {
            ScriptRunning = true;
            UpdateRibbon();

            scriptSession.SetExecutedScript(ScriptItem);
            var parameters = new object[]
            {
                scriptSession,
                scriptToExecute
            };

            var progressBoxRunner = new ScriptRunner(ExecuteInternal, scriptSession, scriptToExecute, autoDispose);

            var rnd = new Random();

            Context.ClientPage.ClientResponse.SetInnerHtml(
                "ScriptResult",
                string.Format(
                    "<div id='PleaseWait'>" +
                    "<img src='../../../../../sitecore modules/PowerShell/Assets/working.gif' alt='Working' />" +
                    "<div>Please wait, {0}</div>" +
                    "</div>" +
                    "<pre ID='ScriptResultCode'></pre>",
                    ExecutionMessages.PleaseWaitMessages[
                        rnd.Next(ExecutionMessages.PleaseWaitMessages.Length - 1)]));

            Context.ClientPage.ClientResponse.Eval("if(cognifide.powershell.preventCloseWhenRunning){cognifide.powershell.preventCloseWhenRunning(true);}");

            scriptSession.Debugging = debug;
            Monitor.Start("ScriptExecution", "UI", progressBoxRunner.Run);

            Monitor.SessionID = scriptSession.ID;
            SheerResponse.Eval("cognifide.powershell.restoreResults();");

            var settings = ApplicationSettings.GetInstance(ApplicationNames.IseConsole);

            if (settings.SaveLastScript)
            {
                settings.Load();
                settings.LastScript = Editor.Value;
                settings.Save();
            }
        }
예제 #25
0
        public virtual void Connect(IPEndPoint ep)
        {
            disconnecting = false;
            disconnected  = false;

            if (Socket == null)
            {
                Socket   = SocketManager.CreateTcp();
                outQueue = new ConcurrentQueue <IPacket>();
                Monitor.Start();
            }

            var task = new SocketConnectTask(ep);

            task.Completed += ConnectCompleted;

            Socket.QueueConnect(task);
        }
예제 #26
0
        private void ExecuteScriptJob(Item scriptItem, ScriptSession scriptSession, Message message, bool autoDispose)
        {
            var script = (scriptItem.Fields[ScriptItemFieldNames.Script] != null)
                ? scriptItem.Fields[ScriptItemFieldNames.Script].Value
                : string.Empty;

            SetVariables(scriptSession, message);

            scriptSession.SetExecutedScript(scriptItem);
            scriptSession.Interactive = true;
            ScriptSessionId           = scriptSession.ID;

            var progressBoxRunner = new ScriptRunner(ExecuteInternal, scriptSession, script, autoDispose);

            Monitor.Start("ScriptExecution", "UI", progressBoxRunner.Run);
            LvProgressOverlay.Visible = false;
            Monitor.SessionID         = scriptSession.ID;
        }
예제 #27
0
        public void Start()
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            //初始化未处理委托
            foreach (var v in Model.LegacyOrders.ToList())
            {
                v.GetSellOpenCountToFreeze();
                Matcher.Handle(v);
            }

            Executor = new OrderExecutor(Model.Traders, this, (t, p) =>
            {
                PosSvc.RaisePC(p, t);
            });
            PosSvc.pds = Executor.pds;
            Executor.OnContractExecuted += (a, b) => { Model.RemoveContract(a, b); };
            Monitor.Start();
        }
예제 #28
0
        static void Main(string[] args)
        {
            Console.WriteLine("Run:");
            Console.WriteLine("1 - Local Monitor");
            Console.WriteLine("2 - Service");

            var input = Console.ReadLine();
            if (input == "1")
            {
                Monitor monitor = new Monitor();
                monitor.AddToWatch("explorer");
                monitor.AddToWatch("calc");
                monitor.AddToWatch("chrome");
                monitor.Start();

                Console.ReadLine();
            }
            else if (input == "2")
            {
                string address = string.Empty; ;
                foreach (IPAddress item in Dns.GetHostAddresses(Dns.GetHostName()))
                {
                    //if (!item.IsIPv6LinkLocal)
                    //    if (!item.IsIPv6Multicast)
                    //        if (!item.IsIPv6SiteLocal)
                    //            if (!item.IsIPv6Teredo)
                    //                address = item.ToString();
                    if (!item.IsIPv6LinkLocal && !item.IsIPv6Multicast && !item.IsIPv6SiteLocal && !item.IsIPv6Teredo)
                        address = item.ToString();
                }

                Monitor monitor = new Monitor();
                using (ServiceHost host = new ServiceHost(monitor, new Uri(string.Format("http://{0}:4325/", address))))
                {
                    host.Open();
                    monitor.Start();
                    Console.WriteLine("Opened...");

                    Console.ReadLine();
                }
            }
        }
예제 #29
0
        static void Main(string[] args)
        {
            TextWriterTraceListener myWriter = new
                                               TextWriterTraceListener(System.Console.Out);

            Trace.Listeners.Add(myWriter);
            var path = args.GetCommandLineArgument("-path", Environment.CurrentDirectory);
            var host = args.GetCommandLineArgument("-host", null);

            int.TryParse(args.GetCommandLineArgument("-port", "5500"), out int port);

            var monitor = new Monitor();

            var started = monitor.Start(path, host, port);

            System.Console.WriteLine("Press Ctrl+C to stop...");
            do
            {
            } while (started);
        }
예제 #30
0
        protected virtual void BuildAndRun(ClientPipelineArgs args, String codeToExecute, Boolean onlyBuild = false)
        {
            this.ScriptRunning = true;
            this.UpdateRibbon();
            var session = GetSession(onlyBuild);
            var runner  = new CodeRunner(BuildCode, session, codeToExecute);

            Context.ClientPage.ClientResponse.SetInnerHtml("ScriptResult", "Build started...");

            Monitor.Start($"Turbo Console", "TCONSOLE", runner.Run);

            var settings = ApplicationSettings.GetInstance(ApplicationNames.Console);

            if (settings.SaveLastScript)
            {
                settings.Load();
                settings.LastScript = Editor.Value;
                settings.Save();
            }
        }
예제 #31
0
        private void ExecuteScriptJob(Item scriptItem, ScriptSession scriptSession, Message message, bool autoDispose)
        {
            if (!scriptItem.IsPowerShellScript())
            {
                SessionElevationErrors.OperationFailedWrongDataTemplate();
                return;
            }

            var script = scriptItem[Templates.Script.Fields.ScriptBody] ?? string.Empty;

            SetVariables(scriptSession, message);
            scriptSession.SetExecutedScript(scriptItem);
            scriptSession.Interactive = true;
            ScriptSessionId           = scriptSession.ID;

            var progressBoxRunner = new ScriptRunner(ExecuteInternal, scriptSession, script, autoDispose);

            Monitor.Start($"SPE - \"{ListViewer?.Data?.Title}\" - \"{scriptItem?.Name}\"", "UI", progressBoxRunner.Run);
            LvProgressOverlay.Visible = false;
            Monitor.SessionID         = scriptSession.ID;
        }
예제 #32
0
        static void Main(string[] args)
        {
            var endOfProcess = new QueuedHandler <CustomsDeclaration> (new NullHandler <CustomsDeclaration>("resident"), "end-of-process");

            var customsAgent1 = new QueuedHandler <CustomsDeclaration>(new CustumsAgent(endOfProcess, "joe"), "agent-joe");
            var customsAgent2 = new QueuedHandler <CustomsDeclaration>(new CustumsAgent(endOfProcess, "jack"), "agent-jack");
            var customsAgent3 = new QueuedHandler <CustomsDeclaration>(new CustumsAgent(endOfProcess, "averell"), "agent-averell");

            var customsAgentDispatcher =
                new RoundRobinDispatcher <CustomsDeclaration>(new[] { customsAgent1, customsAgent2, customsAgent3 });

            var visitorHandler = new NullHandler <CustomsDeclaration>("visitor");


            var residencyRouter = new QueuedHandler <CustomsDeclaration>(new ResidencyRouter(customsAgentDispatcher, visitorHandler), "residency-router");

            residencyRouter.Start();
            customsAgent1.Start();
            customsAgent2.Start();
            customsAgent3.Start();

            var monitor = new Monitor();

            monitor.Add(endOfProcess);
            monitor.Add(customsAgent1);
            monitor.Add(customsAgent2);
            monitor.Add(customsAgent3);
            monitor.Add(residencyRouter);

            monitor.Start();

            var airplane = new Airplane(flight: "DC132", passengersCount: 666, handlesDeclaration: residencyRouter);

            var unload = new Task(airplane.Unload);

            unload.Start();
            unload.Wait();
            System.Console.ReadLine();
        }
예제 #33
0
 public void Start()
 {
     Monitor.Start();
 }
예제 #34
0
 public async Task StartAsync(CancellationToken cancellationToken)
 {
     Logger.LogInformation("Starting");
     Subscribe();
     await Monitor.Start();
 }
예제 #35
0
 public void OnPlay()
 {
     Monitor.Start();
 }