mirror of
https://github.com/caprover/caprover
synced 2026-09-25 08:05:35 +00:00
Blocking non-get requests even if detached build is active
This commit is contained in:
@@ -46,6 +46,7 @@ router.use(function (req, res, next) {
|
||||
return;
|
||||
}
|
||||
|
||||
const serviceManager = res.locals.user.serviceManager;
|
||||
|
||||
// All requests except GET might be making changes to some stuff that are not designed for an asynchronous process
|
||||
// I'm being extra cautious. But removal of this lock mechanism requires testing and consideration of edge cases.
|
||||
@@ -57,6 +58,14 @@ router.use(function (req, res, next) {
|
||||
return;
|
||||
}
|
||||
|
||||
let activeBuildAppName = serviceManager.isAnyBuildRunning();
|
||||
if (activeBuildAppName) {
|
||||
let response = new BaseApi(ApiStatusCodes.STATUS_ERROR_GENERIC,
|
||||
`An active build (${activeBuildAppName}) is in progress... please wait...`);
|
||||
res.send(response);
|
||||
return;
|
||||
}
|
||||
|
||||
// we don't want the same space to go under two simultaneous changes
|
||||
threadLockNamespace[namespace] = true;
|
||||
onFinished(res, function () {
|
||||
|
||||
@@ -818,6 +818,23 @@ class ServiceManager {
|
||||
return !!this.activeBuilds[appName];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns the active build that it finds
|
||||
*/
|
||||
isAnyBuildRunning() {
|
||||
|
||||
let activeBuilds = this.activeBuilds;
|
||||
|
||||
for (let appName in activeBuilds) {
|
||||
if (!!activeBuilds[appName]) {
|
||||
return appName;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
getBuildStatus(appName) {
|
||||
const self = this;
|
||||
this.buildLogs[appName] = this.buildLogs[appName] || new BuildLog(BUILD_LOG_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user