Fixes: 
- Default Nuxt port changed to 3000 (thanks to @yurgeman).
- Cleanup old images effectively.
- More attempts on container startups (3->6).
- Always clean up server logs on restart/redeploy.
This commit is contained in:
Andras Bacsai
2021-04-26 11:45:04 +02:00
committed by GitHub
parent e16b7d65d4
commit b416e3ab3e
8 changed files with 22 additions and 25 deletions

View File

@@ -9,6 +9,7 @@ const { queueAndBuild } = require('../../../libs/applications')
const { setDefaultConfiguration, precheckDeployment } = require('../../../libs/applications/configuration')
const { docker } = require('../../../libs/docker')
const cloneRepository = require('../../../libs/applications/github/cloneRepository')
const { purgeImagesContainers } = require('../../../libs/applications/cleanup')
module.exports = async function (fastify) {
// TODO: Add this to fastify plugin
@@ -93,9 +94,9 @@ module.exports = async function (fastify) {
reply.code(200).send({ message: 'Already in the queue.' })
return
}
queueAndBuild(configuration, imageChanged)
reply.code(201).send({ message: 'Deployment queued.', nickname: configuration.general.nickname, name: configuration.build.container.name })
await queueAndBuild(configuration, imageChanged)
} catch (error) {
const { id, organization, name, branch } = configuration.repository
const { domain } = configuration.publish
@@ -103,7 +104,6 @@ module.exports = async function (fastify) {
await Deployment.findOneAndUpdate(
{ repoId: id, branch, deployId, organization, name, domain },
{ repoId: id, branch, deployId, organization, name, domain, progress: 'failed' })
cleanupTmp(configuration.general.workdir)
if (error.name === 'Error') {
// Error during runtime
await new ApplicationLog({ repoId: id, branch, deployId, event: `[ERROR 😖]: ${error.stack}` }).save()
@@ -114,6 +114,9 @@ module.exports = async function (fastify) {
if (reply.sent) await new ApplicationLog({ repoId: id, branch, deployId, event: `[ERROR 😖]: ${error.stack}` }).save()
}
throw new Error(error)
} finally {
cleanupTmp(configuration.general.workdir)
await purgeImagesContainers(configuration)
}
})
}