public void Init(AdminService adminService)
        {
            string checkFile = Path.Combine(basePath, BlockRunFile);
            if (File.Exists(checkFile))
                adminService.StartService(ServiceType.Block);

            checkFile = Path.Combine(basePath, ManagerRunFile);
            if (File.Exists(checkFile))
                adminService.StartService(ServiceType.Manager);

            checkFile = Path.Combine(basePath, RootRunFile);
            if (File.Exists(checkFile))
                adminService.StartService(ServiceType.Root);
        }
Exemplo n.º 2
0
        public void Init(AdminService adminService)
        {
            string checkFile = Path.Combine(basePath, BlockRunFile);

            if (File.Exists(checkFile))
            {
                adminService.StartService(ServiceType.Block);
            }

            checkFile = Path.Combine(basePath, ManagerRunFile);
            if (File.Exists(checkFile))
            {
                adminService.StartService(ServiceType.Manager);
            }

            checkFile = Path.Combine(basePath, RootRunFile);
            if (File.Exists(checkFile))
            {
                adminService.StartService(ServiceType.Root);
            }
        }
Exemplo n.º 3
0
            public IEnumerable <Message> Process(IEnumerable <Message> request)
            {
                // The message output,
                MessageStream response = new MessageStream();

                // For each message in the message input,
                foreach (Message m in request)
                {
                    try {
                        string command = m.Name;
                        // Report on the services running,
                        if (command.Equals("report"))
                        {
                            lock (service.serverManagerLock) {
                                long tm = System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64;
                                long fm = 0 /* TODO: GetFreeMemory()*/;
                                long td = 0 /* TODO: GetTotalSpace(service.basePath) */;
                                long fd = 0 /* TODO: GetUsableSpace(service.basePath)*/;

                                MachineRoles roles   = MachineRoles.None;
                                Message      message = new Message();
                                if (service.block != null)
                                {
                                    roles |= MachineRoles.Block;
                                }
                                if (service.manager != null)
                                {
                                    roles |= MachineRoles.Manager;
                                }
                                if (service.root != null)
                                {
                                    roles |= MachineRoles.Root;
                                }

                                message.Arguments.Add((byte)roles);
                                message.Arguments.Add(tm - fm);
                                message.Arguments.Add(tm);
                                message.Arguments.Add(td - fd);
                                message.Arguments.Add(td);
                                response.AddMessage(message);
                            }
                        }
                        else if (command.Equals("reportStats"))
                        {
                            // Analytics stats; we convert the stats to a long[] array and
                            // send it as a reply.
                            long[] stats = GetStats();
                            response.AddMessage(new Message(new object[] { stats }));
                        }
                        else
                        {
                            // Starts a service,
                            if (command.Equals("start"))
                            {
                                ServiceType serviceType = (ServiceType)(byte)m.Arguments[0].Value;
                                service.StartService(serviceType);
                            }
                            // Stops a service,
                            else if (command.Equals("stop"))
                            {
                                ServiceType serviceType = (ServiceType)(byte)m.Arguments[0].Value;
                                service.StopService(serviceType);
                            }
                            else
                            {
                                throw new ApplicationException("Unknown command: " + command);
                            }

                            // Add reply message,
                            response.AddMessage(new Message(1L));
                        }
                    } catch (OutOfMemoryException e) {
                        service.Logger.Error("Out-Of-Memory", e);
                        // This will end the connection
                        throw;
                    } catch (Exception e) {
                        service.Logger.Error("Exception during process", e);
                        response.AddMessage(new Message(new MessageError(e)));
                    }
                }
                return(response);
            }