|
|
|
@ -19,14 +19,14 @@ import ( |
|
|
|
|
func Shutdown(ctx context.Context) ResponseExtra { |
|
|
|
|
reqURL := setting.LocalURL + "api/internal/manager/shutdown" |
|
|
|
|
req := newInternalRequest(ctx, reqURL, "POST") |
|
|
|
|
return requestJSONUserMsg(req, "Shutting down") |
|
|
|
|
return requestJSONClientMsg(req, "Shutting down") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Restart calls the internal restart function
|
|
|
|
|
func Restart(ctx context.Context) ResponseExtra { |
|
|
|
|
reqURL := setting.LocalURL + "api/internal/manager/restart" |
|
|
|
|
req := newInternalRequest(ctx, reqURL, "POST") |
|
|
|
|
return requestJSONUserMsg(req, "Restarting") |
|
|
|
|
return requestJSONClientMsg(req, "Restarting") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// FlushOptions represents the options for the flush call
|
|
|
|
@ -42,35 +42,35 @@ func FlushQueues(ctx context.Context, timeout time.Duration, nonBlocking bool) R |
|
|
|
|
if timeout > 0 { |
|
|
|
|
req.SetReadWriteTimeout(timeout + 10*time.Second) |
|
|
|
|
} |
|
|
|
|
return requestJSONUserMsg(req, "Flushed") |
|
|
|
|
return requestJSONClientMsg(req, "Flushed") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// PauseLogging pauses logging
|
|
|
|
|
func PauseLogging(ctx context.Context) ResponseExtra { |
|
|
|
|
reqURL := setting.LocalURL + "api/internal/manager/pause-logging" |
|
|
|
|
req := newInternalRequest(ctx, reqURL, "POST") |
|
|
|
|
return requestJSONUserMsg(req, "Logging Paused") |
|
|
|
|
return requestJSONClientMsg(req, "Logging Paused") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ResumeLogging resumes logging
|
|
|
|
|
func ResumeLogging(ctx context.Context) ResponseExtra { |
|
|
|
|
reqURL := setting.LocalURL + "api/internal/manager/resume-logging" |
|
|
|
|
req := newInternalRequest(ctx, reqURL, "POST") |
|
|
|
|
return requestJSONUserMsg(req, "Logging Restarted") |
|
|
|
|
return requestJSONClientMsg(req, "Logging Restarted") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ReleaseReopenLogging releases and reopens logging files
|
|
|
|
|
func ReleaseReopenLogging(ctx context.Context) ResponseExtra { |
|
|
|
|
reqURL := setting.LocalURL + "api/internal/manager/release-and-reopen-logging" |
|
|
|
|
req := newInternalRequest(ctx, reqURL, "POST") |
|
|
|
|
return requestJSONUserMsg(req, "Logging Restarted") |
|
|
|
|
return requestJSONClientMsg(req, "Logging Restarted") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// SetLogSQL sets database logging
|
|
|
|
|
func SetLogSQL(ctx context.Context, on bool) ResponseExtra { |
|
|
|
|
reqURL := setting.LocalURL + "api/internal/manager/set-log-sql?on=" + strconv.FormatBool(on) |
|
|
|
|
req := newInternalRequest(ctx, reqURL, "POST") |
|
|
|
|
return requestJSONUserMsg(req, "Log SQL setting set") |
|
|
|
|
return requestJSONClientMsg(req, "Log SQL setting set") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// LoggerOptions represents the options for the add logger call
|
|
|
|
@ -90,14 +90,14 @@ func AddLogger(ctx context.Context, logger, writer, mode string, config map[stri |
|
|
|
|
Mode: mode, |
|
|
|
|
Config: config, |
|
|
|
|
}) |
|
|
|
|
return requestJSONUserMsg(req, "Added") |
|
|
|
|
return requestJSONClientMsg(req, "Added") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// RemoveLogger removes a logger
|
|
|
|
|
func RemoveLogger(ctx context.Context, logger, writer string) ResponseExtra { |
|
|
|
|
reqURL := setting.LocalURL + fmt.Sprintf("api/internal/manager/remove-logger/%s/%s", url.PathEscape(logger), url.PathEscape(writer)) |
|
|
|
|
req := newInternalRequest(ctx, reqURL, "POST") |
|
|
|
|
return requestJSONUserMsg(req, "Removed") |
|
|
|
|
return requestJSONClientMsg(req, "Removed") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Processes return the current processes from this gitea instance
|
|
|
|
@ -108,6 +108,6 @@ func Processes(ctx context.Context, out io.Writer, flat, noSystem, stacktraces, |
|
|
|
|
callback := func(resp *http.Response, extra *ResponseExtra) { |
|
|
|
|
_, extra.Error = io.Copy(out, resp.Body) |
|
|
|
|
} |
|
|
|
|
_, extra := requestJSONResp(req, &callback) |
|
|
|
|
_, extra := requestJSONResp(req, &responseCallback{callback}) |
|
|
|
|
return extra |
|
|
|
|
} |
|
|
|
|