Table of Contents

Interface IAppInstanceController

Namespace
VpnHood.AppUi.Hosting.Desktop.Daemon.Platform
Assembly
VpnHood.AppUi.Hosting.Desktop.Daemon.dll

Defines the running instance, the one process on the machine that holds the app, as the commands start, stop and look at it.

public interface IAppInstanceController

Remarks

It is a systemd unit on Linux and a service on Windows; each platform answers in its own terms. The Show calls print for a person and return only an exit code.

Properties

NotRunningHint

Gets the sentence a person reads when nothing is running: what it is, and how to start it.

string NotRunningHint { get; }

Property Value

string

Methods

IsRunning(CancellationToken)

Gets whether the instance is running.

Task<bool> IsRunning(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<bool>

A task whose result is true where it runs.

Exceptions

OperationCanceledException

cancellationToken was canceled.

InvalidOperationException

A system tool the platform runs could not be started.

Restart(CancellationToken)

Restarts the instance.

Task<int> Restart(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<int>

A task whose result is the exit code.

Exceptions

OperationCanceledException

cancellationToken was canceled.

Win32Exception

On Windows, the service control manager refused.

TimeoutException

On Windows, the service did not stop or start in time.

InvalidOperationException

A system tool could not be started, or the instance could not be registered or started again.

ShowOfflineLog(bool, int, CancellationToken)

Prints what the platform keeps of the log itself, for when the service gives none, as for a start that failed before the app opened its log.

Task<int> ShowOfflineLog(bool follow, int lines, CancellationToken cancellationToken)

Parameters

follow bool

true to follow the log as it grows, where the platform can; Windows prints what it has.

lines int

The number of the last lines to print.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<int>

A task whose result is the exit code.

Exceptions

OperationCanceledException

cancellationToken was canceled.

InvalidOperationException

A system tool the platform runs could not be started.

ShowStatus(CancellationToken)

Prints the instance's status for a person.

Task<int> ShowStatus(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<int>

A task whose result is the exit code.

Exceptions

OperationCanceledException

cancellationToken was canceled.

InvalidOperationException

A system tool the platform runs could not be started.

Start(bool, CancellationToken)

Starts the instance.

Task Start(bool mayRegister, CancellationToken cancellationToken)

Parameters

mayRegister bool

true to register a missing instance on the way, behind a prompt, where the app registers its instance itself, as on Windows; a start nobody asked for, as the tray's at sign-in, may not.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

Win32Exception

On Windows, the service control manager refused.

OperationCanceledException

cancellationToken was canceled.

DaemonNotRunningException

The instance is not registered, and mayRegister is false.

InvalidOperationException

The instance could not start; the message says why.

TimeoutException

The instance did not start in time.

Stop(CancellationToken)

Stops the instance.

Task<int> Stop(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<int>

A task whose result is the exit code.

Exceptions

OperationCanceledException

cancellationToken was canceled.

TimeoutException

On Windows, the service did not stop in time.

InvalidOperationException

A system tool the platform runs could not be started.