New features:
- Automatic error reporting (enabled by default)
- Increase build times by leveraging docker build caches
- 
Fixes:
- Fix error handling
- Fix vue autodetect
- Custom dockerfile is not the default

Others:
- Cleanup `logs-servers` collection, because old errors are not standardized
- New Traefik proxy version
- Standardized directory configurations
This commit is contained in:
Andras Bacsai
2021-04-19 09:46:05 +02:00
committed by GitHub
parent bad84289c4
commit 142b83cc13
51 changed files with 1300 additions and 837 deletions

View File

@@ -1,10 +1,18 @@
const dayjs = require('dayjs')
const axios = require('axios')
const ApplicationLog = require('../models/Logs/Application')
const ServerLog = require('../models/Logs/Server')
const dayjs = require('dayjs')
const Settings = require('../models/Settings')
const { version } = require('../../package.json')
function generateTimestamp () {
return `${dayjs().format('YYYY-MM-DD HH:mm:ss.SSS')} `
}
const patterns = [
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
].join('|')
async function saveAppLog (event, configuration, isError) {
try {
@@ -12,25 +20,12 @@ async function saveAppLog (event, configuration, isError) {
const repoId = configuration.repository.id
const branch = configuration.repository.branch
if (isError) {
// console.log(event, config, isError)
let clearedEvent = null
if (event.error) clearedEvent = '[ERROR] ' + generateTimestamp() + event.error.replace(/(\r\n|\n|\r)/gm, '')
else if (event) clearedEvent = '[ERROR] ' + generateTimestamp() + event.replace(/(\r\n|\n|\r)/gm, '')
try {
await new ApplicationLog({ repoId, branch, deployId, event: clearedEvent }).save()
} catch (error) {
console.log(error)
}
const clearedEvent = '[ERROR 😱] ' + generateTimestamp() + event.replace(new RegExp(patterns, 'g'), '').replace(/(\r\n|\n|\r)/gm, '')
await new ApplicationLog({ repoId, branch, deployId, event: clearedEvent }).save()
} else {
if (event && event !== '\n') {
const clearedEvent = '[INFO] ' + generateTimestamp() + event.replace(/(\r\n|\n|\r)/gm, '')
try {
await new ApplicationLog({ repoId, branch, deployId, event: clearedEvent }).save()
} catch (error) {
console.log(error)
}
const clearedEvent = '[INFO] ' + generateTimestamp() + event.replace(new RegExp(patterns, 'g'), '').replace(/(\r\n|\n|\r)/gm, '')
await new ApplicationLog({ repoId, branch, deployId, event: clearedEvent }).save()
}
}
} catch (error) {
@@ -39,20 +34,14 @@ async function saveAppLog (event, configuration, isError) {
}
}
async function saveServerLog ({ event, configuration, type }) {
try {
if (configuration) {
const deployId = configuration.general.deployId
const repoId = configuration.repository.id
const branch = configuration.repository.branch
await new ApplicationLog({ repoId, branch, deployId, event: `[SERVER ERROR 😖]: ${event}` }).save()
}
await new ServerLog({ event, type }).save()
} catch (error) {
// Hmm.
}
}
async function saveServerLog (error) {
const settings = await Settings.findOne({ applicationName: 'coolify' })
const payload = { message: error.message, stack: error.stack, type: error.type || 'spaghetticode', version }
const found = await ServerLog.find(payload)
if (found.length === 0 && error.message) await new ServerLog(payload).save()
if (settings && settings.sendErrors && process.env.NODE_ENV === 'production') await axios.post('https://errors.coollabs.io/api/error', payload)
}
module.exports = {
saveAppLog,
saveServerLog