public void Execute(IService service, ServiceRunningState state) { foreach (var hook in _hooks.Values.Where(x => x.State == state)) { hook.Hook(service); } }
public IService AddHook(ServiceRunningState state, Action <IService> hook, string uniqueName = null) { foreach (var service in Services) { service.AddHook(state, hook, uniqueName); } return(this); }
void IService.Start() { State = ServiceRunningState.Starting; DockerHost.Start(Id, _certificates); if (GetConfiguration().State.Running) { State = ServiceRunningState.Running; } }
public DockerContainerService(string name, string id, DockerUri docker, ServiceRunningState state, ICertificatePaths certificates, bool stopOnDispose = true, bool removeOnDispose = true, bool removeMountOnDispose = false, bool removeNamedMountOnDispose = false, bool isWindowsContainer = false, string instanceId = null, string project = null) : this(name, id, docker, state, certificates, null, stopOnDispose, removeOnDispose, removeMountOnDispose, removeNamedMountOnDispose, isWindowsContainer, instanceId, project) { }
public void Stop() { State = ServiceRunningState.Stopping; var res = DockerHost.Stop(Id, null, _certificates); if (res.Success) { State = ServiceRunningState.Stopped; } }
public DockerContainerService(string name, string id, DockerUri docker, ServiceRunningState state, ICertificatePaths certificates, bool stopOnDispose = true, bool removeOnDispose = true) { _certificates = certificates; _stopOnDispose = stopOnDispose; _removeOnDispose = removeOnDispose; Name = name; Id = id; DockerHost = docker; State = state; }
public void Remove(bool force = false) { if (State != ServiceRunningState.Stopped) { Stop(); } State = ServiceRunningState.Removing; var result = DockerHost.RemoveContainer(Id, force, false, null, _certificates); if (result.Success) { State = ServiceRunningState.Removed; } }
public DockerContainerService(string name, string id, DockerUri docker, ServiceRunningState state, ICertificatePaths certificates, bool stopOnDispose = true, bool removeOnDispose = true, bool removeMountOnDispose = false, bool removeNamedMountOnDispose = false, bool isWindowsContainer = false) { IsWindowsContainer = isWindowsContainer; Certificates = certificates; _removeNamedMountOnDispose = removeNamedMountOnDispose; _removeMountOnDispose = removeMountOnDispose; StopOnDispose = stopOnDispose; RemoveOnDispose = removeOnDispose; Name = name; Id = id; DockerHost = docker; State = state; }
private static void WaitForState(this IContainerService container, ServiceRunningState state) { WaitForStateObject so; using (var mre = new ManualResetEventSlim()) { so = new WaitForStateObject { Mre = mre, Container = container, State = state }; using (new Timer(Callback, so, 0, 500)) { mre.Wait(); } } if (so.Exception != null) { throw so.Exception; } }
public DockerContainerService(string name, string id, DockerUri docker, ServiceRunningState state, ICertificatePaths certificates, Func <Dictionary <string, HostIpEndpoint[]>, string, Uri, IPEndPoint> customEndpointResolver, bool stopOnDispose = true, bool removeOnDispose = true, bool removeMountOnDispose = false, bool removeNamedMountOnDispose = false, bool isWindowsContainer = false, string instanceId = null, string project = null) { IsWindowsContainer = isWindowsContainer; Certificates = certificates; _removeNamedMountOnDispose = removeNamedMountOnDispose; _removeMountOnDispose = removeMountOnDispose; StopOnDispose = stopOnDispose; RemoveOnDispose = removeOnDispose; Name = name; CustomEndpointResolver = customEndpointResolver; Id = id; Service = project ?? string.Empty; InstanceId = instanceId ?? string.Empty; DockerHost = docker; State = state; }
internal StateChangeEventArgs(IService service, ServiceRunningState state) { Service = service; State = state; }
public IService AddHook(ServiceRunningState state, Action <IService> hook, string uniqueName = null) { _hooks.AddHook(uniqueName ?? Guid.NewGuid().ToString(), state, hook); return(this); }
public void AddHook(string uniqueName, ServiceRunningState state, Action <IService> hook) { _hooks.TryAdd(uniqueName, new HookItem { State = state, Hook = hook }); }