Exemplo n.º 1
0
        static void Main(string[] args)
        {
            KillMysql();

            var ports = new SortedDictionary <int, Tuple <string, bool> >
            {
                { 11000, Tuple.Create("Login", true) },
                { 11020, Tuple.Create("Channel", true) },
                { 8002, Tuple.Create("Messenger", false) },
                { 10999, Tuple.Create("Web API", false) },
                { 80, Tuple.Create("HTTP/Hotkeys", false) },
                { 3306, Tuple.Create("MySQL", true) },
            };

            var portTester = new PortTester(ports);

            if (!portTester.Test())
            {
                PrintError("Port check failed, startup aborted");
                Exit(true);
            }

            CheckForHpd();

            if (!File.Exists(GitUrlPath))
            {
                PrintError("URL file 'git_url.txt' not found.");
                Exit(true);
            }

            bool recompileRequired;

            try
            {
                var gitClonePath = File.ReadAllText(GitUrlPath).Trim();
                recompileRequired = new UpdateSource(AuraDir, gitClonePath).Update();
            }
            catch (LibGit2Sharp.LibGit2SharpException ex)
            {
                PrintError("Failed to download or update Aura source, startup aborted (Error: {0})", ex.Message);
                Exit(true);
            }

            recompileRequired = true;             // Hue for the hack.

            if (recompileRequired)
            {
                var compiler = new AuraCompiler(SlnPath, false);

                if (!compiler.Build())
                {
                    PrintError("Recompilation failed due to one or more errors, startup aborted");
                    Exit(true);
                }
            }

            using (var mysql = new MySqlServer(MySqlDPath, MySqlDir, MySqlArgs, MySqlPath))
                using (var servers = new AuraServers(AuraDir, StartServersPath))
                {
                    mysql.Start();

                    if (!File.Exists(MainRunPath))
                    {
                        if (mysql.RunMainSql(MainSqlPath))
                        {
                            File.WriteAllText(MainRunPath, "");
                        }
                        else
                        {
                            PrintError("Main.sql could not be applied. Startup will be terminated.");
                            Exit(true);
                        }
                    }

                    if (!servers.Start())
                    {
                        PrintError("Aura servers could not be started.");
                        Exit(true);
                    }
                    Console.WriteLine();

                    Console.WriteLine("Aura is now running.");
                    Console.WriteLine("Once you have exited all Aura servers, return here and press any key to shut down MySql");

                    Exit(true);
                }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            KillMysql();

            var ports = new SortedDictionary<int, Tuple<string, bool>>
            {
                { 11000, Tuple.Create("Login", true) },
                { 11020, Tuple.Create("Channel", true) },
                { 8002, Tuple.Create("Messenger", false) },
                { 10999, Tuple.Create("Web API", false) },
                { 80, Tuple.Create("HTTP/Hotkeys", false) },
                { 3306, Tuple.Create("MySQL", true) },
            };

            var portTester = new PortTester(ports);

            if (!portTester.Test())
            {
                PrintError("Port check failed, startup aborted");
                Exit(true);
            }

            CheckForHpd();

            var recompileRequired = new UpdateSource(AuraDir, GitClonePath).Update();

            recompileRequired = true; // Hue for the hack.

            if (recompileRequired)
            {
                var compiler = new AuraCompiler(SlnPath, false);

                if (!compiler.Build())
                {
                    PrintError("Recompilation failed due to one or more errors, startup aborted");
                    Exit(true);
                }
            }

            using (var mysql = new MySqlServer(MySqlDPath, MySqlDir, MySqlArgs, MySqlPath))
            using (var servers = new AuraServers(AuraDir, StartServersPath))
            {
                mysql.Start();

                if (!File.Exists(MainRunPath))
                {
                    if (mysql.RunMainSql(MainSqlPath))
                    {
                        File.WriteAllText(MainRunPath, "");
                    }
                    else
                    {
                        PrintError("Main.sql could not be applied. Startup will be terminated.");
                        Exit(true);
                    }
                }

                if (!servers.Start())
                {
                    PrintError("Aura servers could not be started.");
                    Exit(true);
                }
                Console.WriteLine();

                Console.WriteLine("Aura is now running.");
                Console.WriteLine("Once you have exited all Aura servers, return here and press any key to shut down MySql");

                Exit(true);
            }
        }