diff --git a/backend/src/main/java/org/davidbohl/dirigent/deployments/updates/DeploymentUpdateController.java b/backend/src/main/java/org/davidbohl/dirigent/deployments/updates/DeploymentUpdateController.java index fc0e948..f4f7c59 100644 --- a/backend/src/main/java/org/davidbohl/dirigent/deployments/updates/DeploymentUpdateController.java +++ b/backend/src/main/java/org/davidbohl/dirigent/deployments/updates/DeploymentUpdateController.java @@ -27,4 +27,9 @@ public class DeploymentUpdateController { deploymentUpdateService.updateDeployment(deploymentName); } + @PostMapping("check") + public void podtDeploymentUpdateCheck() { + deploymentUpdateService.checkAllDeploymentForUpdates(); + } + } diff --git a/backend/src/main/java/org/davidbohl/dirigent/deployments/updates/DeploymentUpdateService.java b/backend/src/main/java/org/davidbohl/dirigent/deployments/updates/DeploymentUpdateService.java index ada3d0f..f44d915 100644 --- a/backend/src/main/java/org/davidbohl/dirigent/deployments/updates/DeploymentUpdateService.java +++ b/backend/src/main/java/org/davidbohl/dirigent/deployments/updates/DeploymentUpdateService.java @@ -56,6 +56,20 @@ public class DeploymentUpdateService { @Value("${dirigent.compose.command}") private String composeCommand; + + @Transactional + public void updateDeployment(String deploymentName) { + + File deploymentDir = new File("deployments/" + deploymentName); + + String command = this.composeCommand + " pull"; + + processRunner.executeCommand(Arrays.asList(command.split(" ")), deploymentDir); + + this.applicationEventPublisher.publishEvent(new NamedDeploymentStartRequestedEvent(this, deploymentName, true)); + + this.deploymentUpdateRepository.deleteAllByDeploymentName(deploymentName); + } @Scheduled(fixedRateString = "${dirigent.update.rate:3}", timeUnit = TimeUnit.HOURS) public void checkAllDeploymentForUpdates() { @@ -71,20 +85,6 @@ public class DeploymentUpdateService { checkIfImageUpdatesExistForDeployment(deployment); } } - - @Transactional - public void updateDeployment(String deploymentName) { - - File deploymentDir = new File("deployments/" + deploymentName); - - String command = this.composeCommand + " pull"; - - processRunner.executeCommand(Arrays.asList(command.split(" ")), deploymentDir); - - this.applicationEventPublisher.publishEvent(new NamedDeploymentStartRequestedEvent(this, deploymentName, true)); - - this.deploymentUpdateRepository.deleteAllByDeploymentName(deploymentName); - } @Async public void checkIfImageUpdatesExistForDeployment(Deployment deployment) { @@ -129,7 +129,6 @@ public class DeploymentUpdateService { List deploymentUpdates = deploymentUpdateRepository .findAllByDeploymentNameAndServiceAndImage(deployment.name(), service, container.getImage()); - ; if (deploymentUpdates.size() > 0) return; diff --git a/frontend/src/app/api/api.service.ts b/frontend/src/app/api/api.service.ts index 7f6e987..fbbdc58 100644 --- a/frontend/src/app/api/api.service.ts +++ b/frontend/src/app/api/api.service.ts @@ -1,6 +1,6 @@ import {Injectable} from '@angular/core'; import {Observable, ReplaySubject, tap} from 'rxjs'; -import {Deployment} from './deployment'; +import {DeploymentState} from './deployment-state'; import {HttpClient} from '@angular/common/http'; import {Secret} from './secret'; import {SystemInformation} from './system-information'; @@ -11,13 +11,14 @@ import { DeploymentUpdate } from './deployment-update'; }) export class ApiService { - private _deploymentStates: ReplaySubject> = new ReplaySubject>(1); + private _deploymentStates: ReplaySubject> = new ReplaySubject>(1); private _secrets: ReplaySubject> = new ReplaySubject>(1); + private _deploymentUpdates: ReplaySubject> = new ReplaySubject>; constructor(private http: HttpClient) { } - get deploymentStates$(): Observable> { + get deploymentStates$(): Observable> { return this._deploymentStates.asObservable(); } @@ -25,10 +26,22 @@ export class ApiService { return this._secrets.asObservable(); } - updateDeployment(deployment: Deployment): Observable { + get deploymentUpdates$(): Observable> { + return this._deploymentUpdates.asObservable(); + } + + reloadDeployementUpdates(): void { + this.getDeploymentUpdates().subscribe(r => this._deploymentUpdates.next(r)) + } + + updateDeployment(deployment: DeploymentState): Observable { return this.http.post(`api/v1/deployment-updates/${deployment.name}/run`, {}); } + checkForUpdates() { + return this.http.post(`api/v1/deployment-updates/check`, {}); + } + getDeploymentUpdates(): Observable> { return this.http.get>('api/v1/deployment-updates'); } @@ -37,19 +50,19 @@ export class ApiService { this.getAllDeploymentStates().subscribe(r => this._deploymentStates.next(r)); } - getAllDeploymentStates(): Observable> { - return this.http.get>('api/v1/deployments'); + getAllDeploymentStates(): Observable> { + return this.http.get>('api/v1/deployments'); } getSystemInformation(): Observable { return this.http.get('api/v1/system-information'); } - stopDeployment(deploymentState: Deployment): Observable { + stopDeployment(deploymentState: DeploymentState): Observable { return this.http.post(`api/v1/deployments/${deploymentState.name}/stop`, {}); } - startDeployment(deploymentState: Deployment, force: boolean): Observable { + startDeployment(deploymentState: DeploymentState, force: boolean): Observable { return this.http.post(`api/v1/deployments/${deploymentState.name}/start?forceRecreate=${force}`, {}); } diff --git a/frontend/src/app/api/deployment-state.d.ts b/frontend/src/app/api/deployment-state.d.ts new file mode 100644 index 0000000..8f92271 --- /dev/null +++ b/frontend/src/app/api/deployment-state.d.ts @@ -0,0 +1,9 @@ +import { ImageUpdate } from "./image-update"; + +export interface DeploymentState { + name: string; + state: string; + message: string; + source: string; +} + diff --git a/frontend/src/app/api/deployment.d.ts b/frontend/src/app/api/deployment.d.ts deleted file mode 100644 index dd12942..0000000 --- a/frontend/src/app/api/deployment.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -export interface Deployment { - name: string; - state: string; - message: string; - source: string; - imageUpdates: Array -} - -export interface ImageUpdate { - service: string; - image: string; -} diff --git a/frontend/src/app/api/image-update.d.ts b/frontend/src/app/api/image-update.d.ts new file mode 100644 index 0000000..7cd49fa --- /dev/null +++ b/frontend/src/app/api/image-update.d.ts @@ -0,0 +1,5 @@ + +export interface ImageUpdate { + service: string; + image: string; +} diff --git a/frontend/src/app/deployments/deployments.component.html b/frontend/src/app/deployments/deployments.component.html index 411213a..e0a5086 100644 --- a/frontend/src/app/deployments/deployments.component.html +++ b/frontend/src/app/deployments/deployments.component.html @@ -1,9 +1,6 @@
-

Deployments@{{ (systemInformation$ | async)?.instanceName }} ({{ (deployments$ | async)?.length}})

- +

Deployments@{{ (systemInformation$ | async)?.instanceName }} ({{ (deploymentStates$ | async)?.length}})

Search... @@ -16,6 +13,14 @@ } + + View Source