mirror of
https://github.com/caprover/caprover
synced 2026-09-27 17:15:38 +00:00
Fixed nginx
This commit is contained in:
@@ -184,38 +184,7 @@ class LoadBalancerManager {
|
||||
return self.createRootConfFile()
|
||||
})
|
||||
.then(function () {
|
||||
return self.dockerApi
|
||||
.executeCommand(CaptainConstants.nginxServiceName, [
|
||||
'nginx',
|
||||
'-t',
|
||||
])
|
||||
.then(function (result) {
|
||||
// nginx:1.24
|
||||
// Failed example:
|
||||
//
|
||||
// 2024/08/11 22:32:59 [emerg] 28#28: unknown directive "eventsxxx" in /etc/nginx/nginx.conf:8
|
||||
// nginx: [emerg] unknown directive "eventsxxx" in /etc/nginx/nginx.conf:8
|
||||
// nginx: configuration file /etc/nginx/nginx.conf test failed
|
||||
|
||||
// Successful example:
|
||||
//
|
||||
// nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
|
||||
// nginx: configuration file /etc/nginx/nginx.conf test is successful
|
||||
|
||||
if (result.indexOf('test is successful') < 0) {
|
||||
throw ApiStatusCodes.createError(
|
||||
ApiStatusCodes.STATUS_ERROR_NGINX_VALIDATION_FAILED,
|
||||
result
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
.then(function () {
|
||||
Logger.d('sendReloadSignal...')
|
||||
return self.dockerApi.sendSingleContainerKillHUP(
|
||||
CaptainConstants.nginxServiceName
|
||||
)
|
||||
return self.validateNginxConfigAndReload()
|
||||
})
|
||||
.then(function () {
|
||||
Logger.d('SUCCESS: UNLocking NGINX configuration reloading...')
|
||||
@@ -232,6 +201,43 @@ class LoadBalancerManager {
|
||||
})
|
||||
}
|
||||
|
||||
validateNginxConfigAndReload() {
|
||||
const self = this
|
||||
return Promise.resolve()
|
||||
.then(function () {
|
||||
return self.dockerApi.executeCommand(
|
||||
CaptainConstants.nginxServiceName,
|
||||
['nginx', '-t']
|
||||
)
|
||||
})
|
||||
.then(function (result) {
|
||||
// nginx:1.24
|
||||
// Failed example:
|
||||
//
|
||||
// 2024/08/11 22:32:59 [emerg] 28#28: unknown directive "eventsxxx" in /etc/nginx/nginx.conf:8
|
||||
// nginx: [emerg] unknown directive "eventsxxx" in /etc/nginx/nginx.conf:8
|
||||
// nginx: configuration file /etc/nginx/nginx.conf test failed
|
||||
|
||||
// Successful example:
|
||||
//
|
||||
// nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
|
||||
// nginx: configuration file /etc/nginx/nginx.conf test is successful
|
||||
|
||||
if (result.indexOf('test is successful') < 0) {
|
||||
throw ApiStatusCodes.createError(
|
||||
ApiStatusCodes.STATUS_ERROR_NGINX_VALIDATION_FAILED,
|
||||
result
|
||||
)
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
Logger.d('sendReloadSignal...')
|
||||
return self.dockerApi.sendSingleContainerKillHUP(
|
||||
CaptainConstants.nginxServiceName
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
getServerList() {
|
||||
const self = this
|
||||
|
||||
@@ -711,12 +717,6 @@ class LoadBalancerManager {
|
||||
.then(function () {
|
||||
return fs.ensureDir(CaptainConstants.nginxSharedPathOnHost)
|
||||
})
|
||||
.then(function () {
|
||||
Logger.d(
|
||||
'Updating Load Balancer - Setting up NGINX conf file...'
|
||||
)
|
||||
return self.rePopulateNginxConfigFile()
|
||||
})
|
||||
.then(function () {
|
||||
return dockerApi.isServiceRunningByName(
|
||||
CaptainConstants.nginxServiceName
|
||||
@@ -755,6 +755,12 @@ class LoadBalancerManager {
|
||||
return true
|
||||
}
|
||||
})
|
||||
.then(function () {
|
||||
Logger.d(
|
||||
'Updating Load Balancer - Setting up NGINX conf file...'
|
||||
)
|
||||
return self.rePopulateNginxConfigFile()
|
||||
})
|
||||
.then(function () {
|
||||
Logger.d('Updating NGINX service...')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user