Beispiel #1
0
        static internal void PrintBuildServerInfo()
        {
            if (Globals.BuildServerIsDeployed)
            {    // CSScriptLib.CoreExtensions.RunAsync(
                var alive = BuildServer.IsServerAlive(null);
                Console.WriteLine($"Build server deployed: {Globals.build_server.GetFullPath()}");

                var pid = alive ?
                          $" ({BuildServer.PingRemoteInstance(null).Split('\n').FirstOrDefault()})"
                    : "";
                Console.WriteLine($"Build server is {(alive ? "" : "not ")}running{pid}.");
            }
            else
            {
                Console.WriteLine("Build server is not deployed.");
                Console.WriteLine($"Expected deployment: {Globals.build_server.GetFullPath()}");
            }
        }
Beispiel #2
0
 /// <summary>
 /// Pings the running instance of the build server.
 /// </summary>
 static public void Ping()
 {
     Console.WriteLine(BuildServer.PingRemoteInstance(null));
 }
Beispiel #3
0
        static int Main(string[] app_args)
        {
            var exitCode = 0;

            try
            {
                var args = app_args.Where(x => !x.StartsWith("-port:")).ToArray();

                int?port = app_args.FirstOrDefault(x => x.StartsWith("-port:"))?
                           .Replace("-port:", "")
                           .ParseAsPort();

                var csc_file = args.Where(x => x.StartsWith("-csc:"))
                               .Select(x => x.Substring("-csc:".Length).Trim('"'))
                               .FirstOrDefault();

                if (!string.IsNullOrEmpty(csc_file))
                {
                    App.Log($"Setting csc.exe path");

                    BuildServer.csc = csc_file;
                }

                if (args.FirstOrDefault() == "-start")
                {
                    App.Log($"Starting remote instance...");
                    BuildServer.StartRemoteInstance(port);
                }
                else if (args.FirstOrDefault() == "-kill")
                {
                    App.Log($"Stopping all remote instance...");
                    SendShutdownRequest();
                    BuildServer.PurgeRunningHistory();
                }
                else if (args.FirstOrDefault() == "-stop")
                {
                    App.Log($"Stopping remote instance...");
                    App.Log(BuildServer.StopRemoteInstance(port));
                }
                else if (args.FirstOrDefault() == "-restart")
                {
                    App.Log($"Restarting remote instance...");
                    BuildServer.RestartRemoteInstance(port);
                }
                else if (args.FirstOrDefault() == "-ping")
                {
                    App.Log($"Pinging remote instance...");
                    App.Log(BuildServer.PingRemoteInstance(port));
                }
                else if (args.FirstOrDefault() == "-list")
                {
                    App.Log($"Listing remote instances...");
                    App.Log(BuildServer.PingRemoteInstances());
                }
                else if (args.FirstOrDefault() == "-listen")
                {
                    ListenToShutdownRequest();

                    BuildServer.ReportRunning(port);
                    App.Log($"Starting server pid:{ Environment.ProcessId}, port:{port} ");
                    BuildServer.ListenToRequests(port);
                }
                else
                {
                    BuildServer.StartRemoteInstance(port);
                    (var buildLog, _) = BuildServer.SendBuildRequest(args, port);

                    // keep Console as app.log may be swallowing the messages
                    // and the parent process needs to read the console output
                    Console.WriteLine(buildLog);
                }
            }
            catch (Exception e)
            {
                App.Log(e.ToString());
            }
            finally
            {
                BuildServer.ReportExit();
                BuildServer.PurgeRunningHistory();
            }
            return(exitCode);
        }