Skip to content

Commit 14c9f25

Browse files
committed
feat: restart service without pulling the latest image
1 parent 5da1f48 commit 14c9f25

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

app/Livewire/Project/Service/Navbar.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,21 @@ public function restart()
108108

109109
return;
110110
}
111+
StopService::run(service: $this->service, dockerCleanup: false);
112+
$this->service->parse();
113+
$this->dispatch('imagePulled');
114+
$activity = StartService::run($this->service);
115+
$this->dispatch('activityMonitor', $activity->id);
116+
}
117+
118+
public function pullAndRestartEvent()
119+
{
120+
$this->checkDeployments();
121+
if ($this->isDeploymentProgress) {
122+
$this->dispatch('error', 'There is a deployment in progress.');
123+
124+
return;
125+
}
111126
PullImage::run($this->service);
112127
StopService::run(service: $this->service, dockerCleanup: false);
113128
$this->service->parse();

resources/views/livewire/project/service/navbar.blade.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,34 @@
2222
</nav>
2323
<div class="flex flex-wrap order-first gap-2 items-center sm:order-last">
2424
@if (str($service->status())->contains('running'))
25-
<button @click="$wire.dispatch('restartEvent')" class="gap-2 button">
25+
<x-dropdown>
26+
<x-slot:title>
27+
Advanced
28+
</x-slot>
29+
<div class="dropdown-item" @click="$wire.dispatch('pullAndRestartEvent')">
30+
<svg xmlns="http://www.w3.org/2000/svg" class="w-6 h-6" viewBox="0 0 24 24" stroke-width="1.5"
31+
stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
32+
<path stroke="none" d="M0 0h24v24H0z" fill="none" />
33+
<path
34+
d="M12.983 8.978c3.955 -.182 7.017 -1.446 7.017 -2.978c0 -1.657 -3.582 -3 -8 -3c-1.661 0 -3.204 .19 -4.483 .515m-2.783 1.228c-.471 .382 -.734 .808 -.734 1.257c0 1.22 1.944 2.271 4.734 2.74" />
35+
<path
36+
d="M4 6v6c0 1.657 3.582 3 8 3c.986 0 1.93 -.067 2.802 -.19m3.187 -.82c1.251 -.53 2.011 -1.228 2.011 -1.99v-6" />
37+
<path d="M4 12v6c0 1.657 3.582 3 8 3c3.217 0 5.991 -.712 7.261 -1.74m.739 -3.26v-4" />
38+
<path d="M3 3l18 18" />
39+
</svg>
40+
Pull Latest Images & Restart
41+
</div>
42+
</x-dropdown>
43+
<x-forms.button title="Restart" @click="$wire.dispatch('restartEvent')">
2644
<svg class="w-5 h-5 dark:text-warning" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
2745
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
2846
stroke-width="2">
2947
<path d="M19.933 13.041a8 8 0 1 1-9.925-8.788c3.899-1 7.935 1.007 9.425 4.747" />
3048
<path d="M20 4v5h-5" />
3149
</g>
3250
</svg>
33-
Pull Latest Images & Restart
34-
</button>
51+
Restart
52+
</x-forms.button>
3553
<x-modal-confirmation title="Confirm Service Stopping?" buttonTitle="Stop" submitAction="stop"
3654
:checkboxes="$checkboxes" :actions="[__('service.stop'), __('resource.non_persistent')]" :confirmWithText="false" :confirmWithPassword="false" step1ButtonText="Continue"
3755
step2ButtonText="Stop Service" :dispatchEvent="true" dispatchEventType="stopEvent">
@@ -135,9 +153,13 @@
135153
$wire.$call('start');
136154
});
137155
$wire.$on('restartEvent', () => {
138-
$wire.$dispatch('info', 'Pulling new images.');
156+
$wire.$dispatch('info', 'Service restart in progress.');
139157
$wire.$call('restart');
140158
});
159+
$wire.$on('pullAndRestartEvent', () => {
160+
$wire.$dispatch('info', 'Pulling new images.');
161+
$wire.$call('pullAndRestartEvent');
162+
});
141163
$wire.on('imagePulled', () => {
142164
window.dispatchEvent(new CustomEvent('startservice'));
143165
$wire.$dispatch('info', 'Restarting service.');

0 commit comments

Comments
 (0)