Esempio n. 1
0
        public string GetIconPath(string applicationId)
        {
            RepoApplicationDescriptor applicationDescriptor = GetApplicationDescriptor(applicationId);
            string iconPath = Path.Combine(applicationDescriptor.ManifestPath, applicationDescriptor.Manifest.IconPath);

            return(iconPath);
        }
Esempio n. 2
0
        private ProcessStartInfo GenerateProcessStartInfo(RepoApplicationDescriptor repoApplicationDescriptor)
        {
            var processStartInfo = new ProcessStartInfo(repoApplicationDescriptor.Manifest.CommandLine, string.Join(" ", repoApplicationDescriptor.Manifest.CommandLineParams));

            processStartInfo.WorkingDirectory = repoApplicationDescriptor.WorkingDirectory;
            processStartInfo.UseShellExecute  = true;
            return(processStartInfo);
        }
Esempio n. 3
0
        public ApplicationStatus GetStatus(string applicationId)
        {
            RepoApplicationDescriptor item = m_InstalledApplications.GetValueOrDefault(applicationId);

            if (item == null)
            {
                throw new Exception("No such applicationid: " + applicationId);
            }
            return(new ApplicationStatus
            {
                ApplicationManifest = item.Manifest,
                IsRunning = IsAlive(applicationId),
                WorkingDirectory = item.WorkingDirectory
            });
        }
Esempio n. 4
0
        public void Start(string applicationId)
        {
            ApplicationInfo info = GetRunningApplicationInfo(applicationId);

            if (info?.IsRunning() ?? false)
            {
                Console.WriteLine($"applicationid {applicationId} is already running!");
                return;
            }
            Console.WriteLine($"Starting {applicationId}..");
            RepoApplicationDescriptor descriptor = GetApplicationDescriptor(applicationId);

            Console.WriteLine($"Generate process start info for {applicationId}...");
            ProcessStartInfo pInfo = GenerateProcessStartInfo(descriptor);

            Console.WriteLine("Executing: WorkingDirectory: " + pInfo.WorkingDirectory + ", process: " + pInfo.FileName + " " + pInfo.Arguments);
            try
            {
                var(task, process) = ProcessHandler.StartProcess(pInfo);
                if (process.HasExited)
                {
                    Console.WriteLine("process exited with error code " + process.ExitCode);
                }
                process.EnableRaisingEvents = true;
                string moduleName = process.MainModule.ModuleName;
                var    aInfo      = new ApplicationInfo {
                    Descriptor = descriptor, Process = process, Task = task
                };
                m_RunningApplications.TryAdd(descriptor.Manifest.ApplicationId, aInfo);

                process.Exited += (_, __) =>
                {
                    ApplicationInfo app;
                    Console.WriteLine(moduleName + " exited at " + process.ExitTime);
                    m_RunningApplications.TryRemove(applicationId, out app);
                    if (!app.RequestStop && descriptor.Manifest.RestartOnUnexpectedDeath)
                    {
                        Start(applicationId);
                    }
                };
            }
            catch (Exception e)
            {
                Console.WriteLine(e.GetType().Name);
                Console.WriteLine(e.Message);
            }
        }
Esempio n. 5
0
        public void DeployAndInstall(ZipArchive archive)
        {
            ZipArchiveEntry archiveEntry = archive.Entries.FirstOrDefault(item => Path.GetExtension(item.Name).Equals(m_ApplicationRepository.ManifestExtension, StringComparison.InvariantCultureIgnoreCase));

            if (archiveEntry == null)
            {
                throw new Exception("No app descriptor");
            }

            using (Stream stream = archiveEntry.Open())
            {
                RepoApplicationDescriptor appDescriptor = m_ApplicationRepository.AddApplication(stream, archive);
                if (appDescriptor == null)
                {
                    throw new Exception("Could not evaluate " + nameof(ApplicationManifest));
                }
                Install(appDescriptor);
            }
        }
Esempio n. 6
0
 void Install(RepoApplicationDescriptor repoApplicationDescriptor)
 {
     m_InstalledApplications.AddOrUpdate(repoApplicationDescriptor.Manifest.ApplicationId, repoApplicationDescriptor, (_, __) => repoApplicationDescriptor);
 }