FIX: Cleanup Script

This commit is contained in:
Nishan
2025-04-10 12:12:22 +05:30
parent c9005dc150
commit c7bf53c630
5 changed files with 17 additions and 7 deletions

View File

@@ -381,6 +381,13 @@ document.addEventListener('DOMContentLoaded', function() {
showLoadingOverlay(); // Show the loading overlay instead of pageLoader
updateLoadingMessage('Starting lab environment...');
updateExamInfo(`Lab: ${selectedLab.name} | Difficulty: ${selectedLab.difficulty || 'Medium'}`);
let userAgent = '';
try {
userAgent = navigator.userAgent;
} catch (error) {
console.error('Error getting user agent:', error);
}
selectedLab.userAgent = userAgent;
// Make a POST request to the facilitator API - using exams endpoint for POST
fetch('/facilitator/api/v1/exams/', {
@@ -474,7 +481,7 @@ document.addEventListener('DOMContentLoaded', function() {
} catch (error) {
console.error('Error polling exam status:', error);
// Show error in the loading overlay
updateLoadingMessage(`Error checking exam status: ${error.message}. Retrying in ${pollInterval/1000}s...`);
updateLoadingMessage(`Error: ${error.message}. Retrying...`);
// Continue polling despite errors
setTimeout(poll, pollInterval);
}

View File

@@ -66,6 +66,9 @@ async function createExam(examData) {
category: examData.category,
labId: examData.config.lab,
examName: examData.name,
event: {
userAgent: examData.userAgent
}
});
return {

View File

@@ -55,7 +55,7 @@ async function getClient() {
* @param {number} [ttl=3600] - Time to live in seconds (default: 1 hour)
* @returns {Promise<string>} - Returns 'OK' if successful
*/
async function persistExamInfo(examId, examInfo, ttl = 36000) {
async function persistExamInfo(examId, examInfo, ttl = 3600000) {
try {
const client = await getClient();
const key = `${KEYS.EXAM_INFO}${examId}`;
@@ -76,7 +76,7 @@ async function persistExamInfo(examId, examInfo, ttl = 36000) {
* @param {number} [ttl=3600] - Time to live in seconds (default: 1 hour)
* @returns {Promise<string>} - Returns 'OK' if successful
*/
async function persistExamStatus(examId, status, ttl = 36000) {
async function persistExamStatus(examId, status, ttl = 3600000) {
try {
const client = await getClient();
const key = `${KEYS.EXAM_STATUS}${examId}`;
@@ -96,7 +96,7 @@ async function persistExamStatus(examId, status, ttl = 36000) {
* @param {number} [ttl=3600] - Time to live in seconds (default: 1 hour)
* @returns {Promise<string>} - Returns 'OK' if successful
*/
async function persistExamResult(examId, result, ttl = 36000) {
async function persistExamResult(examId, result, ttl = 3600000) {
try {
const client = await getClient();
const key = `${KEYS.EXAM_RESULT}${examId}`;
@@ -117,7 +117,7 @@ async function persistExamResult(examId, result, ttl = 36000) {
* @param {number} [ttl=3600] - Time to live in seconds (default: 1 hour)
* @returns {Promise<string>} - Returns 'OK' if successful
*/
async function setCurrentExamId(examId, ttl = 36000) {
async function setCurrentExamId(examId, ttl = 3600000) {
try {
const client = await getClient();
const result = await client.setEx(KEYS.CURRENT_EXAM_ID, ttl, examId);

View File

@@ -333,7 +333,7 @@ try {
Write-ColorOutput "CK-X Simulator has been installed in: " -NoNewline
Write-ColorOutput "$(Get-Location), run all below commands from this directory" "Green"
Write-ColorOutput "To stop CK-X: " -NoNewline
Write-ColorOutput "docker compose down" "Green"
Write-ColorOutput "docker compose down --volumes --remove-orphans --rmi all" "Green"
Write-ColorOutput "To Restart CK-X: " -NoNewline
Write-ColorOutput "docker compose restart" "Green"
Write-ColorOutput "To clean up all containers and images: " -NoNewline

View File

@@ -221,7 +221,7 @@ main() {
echo -e "\n${BLUE}Useful Commands${NC}"
echo -e "${CYAN}==============================================================${NC}"
echo -e "${YELLOW}CK-X Simulator has been installed in:${NC} ${GREEN}$(pwd)${NC}, run all below commands from this directory"
echo -e "${YELLOW}To stop CK-X ${GREEN}docker compose down${NC}"
echo -e "${YELLOW}To stop CK-X ${GREEN}docker compose down --volumes --remove-orphans --rmi all${NC}"
echo -e "${YELLOW}To Restart CK-X:${NC} ${GREEN}docker compose restart${NC}"
echo -e "${YELLOW}To clean up all containers and images:${NC} ${GREEN}docker system prune -a${NC}"
echo -e "${YELLOW}To remove only CK-X images:${NC} ${GREEN}docker compose down --rmi all${NC}"