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

Function StartInstanceHander

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

Source from the content-addressed store, hash-verified

210}
211
212func StartInstanceHander(ctx *gin.Context) {
213 var req ginmodel.SingleInstanceRequest
214 if err := ctx.Bind(&req); err != nil {
215 jsonResp := ginmodel.JsonResp{
216 Code: -1,
217 Message: fmt.Sprintf("Invalid Request Data: %s", err.Error()),
218 }
219 ctx.JSON(http.StatusBadRequest, jsonResp)
220 return
221 }
222
223 err := synchronizer.UpdateInstanceInfo(req.NodeIndex, req.InstanceID, func(i *model.Instance) error {
224 i.Start = true
225 return nil
226 })
227 if err != nil {
228 jsonResp := ginmodel.JsonResp{
229 Code: -1,
230 Message: fmt.Sprintf("Start Instance Error: %s", err.Error()),
231 }
232 ctx.JSON(http.StatusInternalServerError, jsonResp)
233 return
234 }
235 jsonResp := ginmodel.JsonResp{
236 Code: 0,
237 Message: "Success",
238 }
239 ctx.JSON(http.StatusOK, jsonResp)
240}
241
242func StopInstanceHandler(ctx *gin.Context) {
243 var req ginmodel.SingleInstanceRequest

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected