MCPcopy Create free account
hub / github.com/compozy/agh / restartDaemonAfterUpdate

Function restartDaemonAfterUpdate

internal/cli/update.go:163–241  ·  view source on GitHub ↗
(
	cmd *cobra.Command,
	deps commandDeps,
	manager updateManager,
	runtime *runtimeContext,
	applied aghupdate.AppliedBinary,
	release *aghupdate.Release,
	record updateRecord,
)

Source from the content-addressed store, hash-verified

161}
162
163func restartDaemonAfterUpdate(
164 cmd *cobra.Command,
165 deps commandDeps,
166 manager updateManager,
167 runtime *runtimeContext,
168 applied aghupdate.AppliedBinary,
169 release *aghupdate.Release,
170 record updateRecord,
171) error {
172 client, err := clientFromDeps(deps)
173 if err != nil {
174 return failAppliedUpdate(
175 cmd,
176 manager,
177 applied,
178 deps,
179 runtime,
180 record,
181 "Updated the binary on disk, but failed to prepare daemon restart.",
182 err,
183 false,
184 )
185 }
186
187 restartAction, err := client.TriggerSettingsRestart(cmd.Context())
188 if err != nil {
189 return failAppliedUpdate(
190 cmd,
191 manager,
192 applied,
193 deps,
194 runtime,
195 record,
196 "Updated the binary on disk, but failed to trigger daemon restart.",
197 err,
198 false,
199 )
200 }
201
202 restartStatus, err := waitForSettingsRestart(cmd.Context(), deps, client, restartAction.OperationID)
203 if err != nil {
204 return failAppliedUpdate(
205 cmd,
206 manager,
207 applied,
208 deps,
209 runtime,
210 record,
211 "Updated the binary on disk, but the daemon restart did not complete successfully.",
212 err,
213 true,
214 )
215 }
216 if strings.TrimSpace(string(restartStatus.Status)) != restartStatusReady {
217 restartErr := fmt.Errorf("cli: daemon restart finished in unexpected state %q", restartStatus.Status)
218 return failAppliedUpdate(
219 cmd,
220 manager,

Callers 1

applyAvailableUpdateFunction · 0.85

Calls 9

clientFromDepsFunction · 0.85
failAppliedUpdateFunction · 0.85
waitForSettingsRestartFunction · 0.85
writeUpdateFailureFunction · 0.85
writeCommandOutputFunction · 0.85
updateBundleFunction · 0.85
FinalizeMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected