Beispiel #1
0
        private void StartDaemon(DaemonDto dto)
        {
            Logger.Trace("Daemon {0} starting {1}...", dto.Id, dto.Info("Path|Args"));
            var rt = new DaemonRT(dto, root, delay);

            running.Add(rt.Id, rt);
            starting.Remove(dto.Id);
            Logger.Trace("Daemon {0} started {1}", rt.Id, rt.Info("Name|Pid"));
        }
        private void ExecuteInstall(IStream io, params string[] tokens)
        {
            var id = tokens[2];

            installed.TryGetValue(id, out var dto);
            AssertTools.True(dto == null, "Daemon {0} already installed", id);
            AssertTools.True(Regex.IsMatch(id, "[a-zA_Z][a-zA_Z0-9_]*"), "Invalid id {0}", id);
            var exe = tokens[3];

            AssertTools.True(PathTools.IsChildPath(root, exe), "Invalid path {0}", exe);
            dto = new DaemonDto
            {
                Id   = id,
                Path = tokens[3],
                Args = DaemonProcess.MakeCli(tokens, 4),
            };
            var path = PathTools.Combine(root, dto.Path);

            AssertTools.True(File.Exists(path), "File {0} not found", dto.Path);
            Database.Save(database, dto);
            io.WriteLine("Daemon {0} installed as {1}", id, dto.Info("Path|Args"));
            ReloadDatabase();
        }
Beispiel #3
0
 //string id for equality check
 private string Sid(DaemonDto dto) => dto.Info("Id|Path|Args");