コード例 #1
0
        static void Main(string[] args)
        {
            var programArgs = ParseArgs(args);

            if (programArgs.Count == 0)
            {
                Console.WriteLine("Please specify applications to start and watch. For example:");
                Console.WriteLine("Start and monitor one app:");
                Console.WriteLine("supervisor myapp.exe");
                Console.WriteLine("Start and monitor two apps:");
                Console.WriteLine("supervisor app1.exe app2.exe");
                Console.WriteLine("Start and monitor two apps with arguments:");
                Console.WriteLine("supervisor \"app1.exe \"\"argument 1\"\"\" \"\"\"Folder Name\\app1.exe\"\" \"\"argument 1\"\"\"");
                return;
            }

            var threads = new List <MonitorThread>(programArgs.Count);

            for (int i = 0; i < programArgs.Count; i++)
            {
                var t = new MonitorThread(programArgs[i]);
                threads.Add(t);
            }

            Console.WriteLine("Press enter to stop all processes.");
            Console.ReadLine();
            for (int i = 0; i < threads.Count; i++)
            {
                threads[i].Stop();
            }
            for (int i = 0; i < threads.Count; i++)
            {
                threads[i].Join();
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("Please provide a YAML config file with applications to start and watch. For example:");
                Console.WriteLine("supervisor myapps.yaml");
                return;
            }
            for (int i = 1; i < args.Length; i++)
            {
                Console.WriteLine("WARNING: The argument '{0}' will be ingored", args[i]);
            }
            var apps = ParseYamlConfig(args[0]);

            if (apps.Count == 0)
            {
                Console.WriteLine("The YAML config file '{0}' is invalid", args[0]);
                Console.WriteLine("Please fix your YAML config file");
                return;
            }

            var threads = new List <MonitorThread>(apps.Count);

            for (int i = 0; i < apps.Count; i++)
            {
                var t = new MonitorThread(apps[i]);
                threads.Add(t);
            }

            Console.WriteLine("Press enter to stop all processes.");
            Console.ReadLine();
            for (int i = 0; i < threads.Count; i++)
            {
                threads[i].Stop();
            }
            for (int i = 0; i < threads.Count; i++)
            {
                threads[i].Join();
            }
        }