Feature/restart service (#1554)

* add restart button to service show page and restart rpc api

* Feature/restart rpc (#1555)

* add restart rpc and status

* wire up rpc

* add restarting bool

Co-authored-by: Aiden McClelland <me@drbonez.dev>

* check if service is restarting

* filter package when restarting to avoid glitch

Co-authored-by: Aiden McClelland <me@drbonez.dev>
This commit is contained in:
Lucy C
2022-06-17 20:11:15 -06:00
parent 889cf03c1c
commit a4a8f33df0
18 changed files with 212 additions and 64 deletions

View File

@@ -36,7 +36,7 @@ export class MockApiService extends ApiService {
value: mockPatchData,
expireId: null,
})
private readonly revertTime = 4000
private readonly revertTime = 2000
sequence: number
constructor(private readonly bootstrapper: LocalStorageBootstrap) {
@@ -654,6 +654,63 @@ export class MockApiService extends ApiService {
return this.withRevision(originalPatch)
}
async restartPackageRaw(
params: RR.RestartPackageReq,
): Promise<RR.RestartPackageRes> {
// first enact stop
await pauseFor(2000)
const path = `/package-data/${params.id}/installed/status/main`
setTimeout(() => {
const patch2 = [
{
op: PatchOp.REPLACE,
path: path + '/status',
value: PackageMainStatus.Running,
},
{
op: PatchOp.REPLACE,
path: path + '/health',
value: {
'ephemeral-health-check': {
result: 'starting',
},
'unnecessary-health-check': {
result: 'disabled',
},
'chain-state': {
result: 'loading',
message: 'Bitcoin is syncing from genesis',
},
'p2p-interface': {
result: 'success',
},
'rpc-interface': {
result: 'failure',
error: 'RPC interface unreachable.',
},
},
} as any,
]
this.updateMock(patch2)
}, this.revertTime)
const patch = [
{
op: PatchOp.REPLACE,
path: path + '/status',
value: PackageMainStatus.Restarting,
},
{
op: PatchOp.REPLACE,
path: path + '/health',
value: {},
},
]
return this.withRevision(patch)
}
async stopPackageRaw(params: RR.StopPackageReq): Promise<RR.StopPackageRes> {
await pauseFor(2000)
const path = `/package-data/${params.id}/installed/status/main`