Features:
- Rust support 🦀 (Thanks to @pepoviola)
- Add a default rewrite rule to PHP apps (to index.php)
- Able to control upgrades in a straightforward way
Fixes:
- Improved upgrade scripts
- Simplified prechecks before deployment
- Fixed path deployments
- Fixed already defined apps redirections
- Better error handling - still needs a lot of improvement here!
		
	
			
		
			
				
	
	
		
			60 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			1.8 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const ApplicationLog = require('../models/Logs/Application')
 | |
| const ServerLog = require('../models/Logs/Server')
 | |
| const dayjs = require('dayjs')
 | |
| 
 | |
| function generateTimestamp () {
 | |
|   return `${dayjs().format('YYYY-MM-DD HH:mm:ss.SSS')} `
 | |
| }
 | |
| 
 | |
| async function saveAppLog (event, configuration, isError) {
 | |
|   try {
 | |
|     const deployId = configuration.general.deployId
 | |
|     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)
 | |
|       }
 | |
|     } 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)
 | |
|         }
 | |
|       }
 | |
|     }
 | |
|   } catch (error) {
 | |
|     console.log(error)
 | |
|     return error
 | |
|   }
 | |
| }
 | |
| 
 | |
| 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.
 | |
|   }
 | |
| }
 | |
| 
 | |
| module.exports = {
 | |
|   saveAppLog,
 | |
|   saveServerLog
 | |
| }
 |