MCPcopy Create free account
hub / github.com/OpenSN-Library/OpenSN-Library / StopInstanceHandler

Function StopInstanceHandler

daemon/pkg/handler/instance_handler.go:242–270  ·  view source on GitHub ↗
(ctx *gin.Context)

Source from the content-addressed store, hash-verified

240}
241
242func StopInstanceHandler(ctx *gin.Context) {
243 var req ginmodel.SingleInstanceRequest
244 if err := ctx.Bind(&req); err != nil {
245 jsonResp := ginmodel.JsonResp{
246 Code: -1,
247 Message: fmt.Sprintf("Invalid Request Data: %s", err.Error()),
248 }
249 ctx.JSON(http.StatusBadRequest, jsonResp)
250 return
251 }
252
253 err := synchronizer.UpdateInstanceInfo(req.NodeIndex, req.InstanceID, func(i *model.Instance) error {
254 i.Start = false
255 return nil
256 })
257 if err != nil {
258 jsonResp := ginmodel.JsonResp{
259 Code: -1,
260 Message: fmt.Sprintf("Stop Instance Error: %s", err.Error()),
261 }
262 ctx.JSON(http.StatusInternalServerError, jsonResp)
263 return
264 }
265 jsonResp := ginmodel.JsonResp{
266 Code: 0,
267 Message: "Success",
268 }
269 ctx.JSON(http.StatusOK, jsonResp)
270}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected