Esempio n. 1
0
        private void ConfigureAppsOnBootComplete()
        {
            if (string.IsNullOrWhiteSpace(this.Reservation.RunningInstance[0].PublicDnsName) ||
                string.IsNullOrWhiteSpace(this.ConsoleOutput))
            {
                return;
            }

            //We will hardcode this for a while
            Program.TraceLine("Configuring apps through SSH");
            Program.Tracer.Trace(false, "ssh>" + SshClient.GetResponse().Replace("\n", "\nssh>"));
            //Program.Tracer.TraceLine(false, "sudo su");
            this.SshClient.SendLine("sudo su", true);
            Program.Tracer.Trace(false, SshClient.GetResponse().Replace("\n", "\nssh>"));
            foreach (var app in this.myController.runningApps)
            {
                if (app.DeployedOnInstanceId == this.InstanceId)
                {
                    //Program.Tracer.TraceLine(false, "bash /var/rails_apps/{0}/STARTME > /var/log/app_init_{0}", app.AppName);
                    this.SshClient.SendLine(string.Format("bash /var/rails_apps/{0}/STARTME" /* > /var/log/app_init_{0}"*/, app.AppName), true, 10 * 60 * 1000);
                    Program.Tracer.Trace(false, SshClient.GetResponse().Replace("\n", "\nssh>"));
                }
            }
            this.SshClient.SendLine("reboot");
            Thread.Sleep(1000);
            Program.Tracer.Trace(false, SshClient.GetResponse().Replace("\n", "\nssh>"));
            this.SshClient.Close();
            Program.Tracer.TraceLine("\nssh>SSH DISCONNECTED.");
            //ConfigureAppsWhenBootingComplete = 0;
        }