added email verification
This commit is contained in:
@@ -1,50 +1,43 @@
|
||||
import { BackupRetrievalWorker } from '../helpers/backup_retrieval';
|
||||
import dotenv from 'dotenv';
|
||||
import { BackupRetrievalWorker } from '../helpers/backup_retrieval'
|
||||
import dotenv from 'dotenv'
|
||||
|
||||
// Load environment variables from .env file if it exists
|
||||
dotenv.config();
|
||||
dotenv.config()
|
||||
|
||||
// Retrieve configuration from environment variables
|
||||
const userConfigPath = process.env.USER_CONFIG_PATH as string;
|
||||
const applicationInfoPath = process.env.APPLICATION_INFO_PATH as string;
|
||||
const clientPort = Number(process.env.CLIENT_PORT);
|
||||
const destinationPath = process.env.DESTINATION_PATH as string;
|
||||
const clientPort = Number(process.env.CLIENT_PORT)
|
||||
const destinationPath = process.env.DESTINATION_PATH as string
|
||||
const pathToDatabaseFile = process.env.DATABASE_FILE_PATH as string
|
||||
|
||||
// Validate that all required environment variables are present
|
||||
if (!userConfigPath || !applicationInfoPath || !clientPort || !destinationPath) {
|
||||
console.error('Error: Missing required environment variables.');
|
||||
process.exit(1);
|
||||
if (!pathToDatabaseFile || !clientPort || !destinationPath) {
|
||||
console.error('Error: Missing required environment variables.')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
// Initialize the BackupRetrievalWorker
|
||||
const backupRetrievalWorker = new BackupRetrievalWorker(
|
||||
userConfigPath,
|
||||
applicationInfoPath,
|
||||
clientPort,
|
||||
destinationPath
|
||||
);
|
||||
pathToDatabaseFile,
|
||||
clientPort,
|
||||
destinationPath,
|
||||
)
|
||||
|
||||
// Start the backup retrieval process
|
||||
backupRetrievalWorker.start().then(() => {
|
||||
console.log('Backup retrieval process completed successfully.');
|
||||
});
|
||||
console.log('Backup retrieval process completed successfully.')
|
||||
})
|
||||
|
||||
process.on('SIGTERM', async () => {
|
||||
console.log('Received SIGTERM. Cleaning up...');
|
||||
await cleanupAndExit();
|
||||
});
|
||||
console.log('Received SIGTERM. Cleaning up...')
|
||||
await cleanupAndExit()
|
||||
})
|
||||
|
||||
process.on('SIGINT', async () => {
|
||||
console.log('Received SIGINT. Cleaning up...');
|
||||
await cleanupAndExit();
|
||||
});
|
||||
console.log('Received SIGINT. Cleaning up...')
|
||||
await cleanupAndExit()
|
||||
})
|
||||
|
||||
async function cleanupAndExit() {
|
||||
// Perform any cleanup, such as closing connections, saving data, etc.
|
||||
// Example: if you have a server instance running, you may want to close it:
|
||||
// await server.close();
|
||||
|
||||
console.log('Cleanup complete. Exiting.');
|
||||
process.exit(0); // Exit with code 0 to indicate a clean exit
|
||||
console.log('Cleanup complete. Exiting.')
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user