Example #1
0
        public async Task StartServerById(string id, int maxRamMB, int minRamMB)
        {
            var server = await _repo.GetServerById(id);

            if (server == null)
            {
                // TODO: Add error handling here
                return;
            }
            if (_runningServers.ContainsKey(id))
            {
                // TODO: Add error handling here
                return;
            }

            var serverProcess = new ServerProcess(server.Id, maxRamMB, minRamMB);

            _runningServers.TryAdd(server.Id, serverProcess);
            var pId = serverProcess.StartServer(_logger, _angularHub);

            server.MaxRamMB  = maxRamMB;
            server.MinRamMB  = minRamMB;
            server.ProcessId = pId;
            server.IsRunning = true;
            server.TimesRan++;
            await _repo.UpsertServer(server);

            return;
        }