forked from Danielznn16/DDBS-Final
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinitialization.sh
More file actions
executable file
·61 lines (46 loc) · 1.67 KB
/
initialization.sh
File metadata and controls
executable file
·61 lines (46 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Set error handling
set -e
echo "Starting system initialization..."
# Script locations
DB_SCRIPTS="./scripts/db"
STORAGE_SCRIPTS="./scripts/storage"
BACKUP_SCRIPTS="./scripts/backup"
UTILS_SCRIPTS="./scripts/utils"
# Clean up and prepare directories
echo "Preparing directories..."
rm -rf ./ddbs_1_data ./ddbs_2_data ./dfs_1_data ./dfs_2_data
rm -f db-generation/articles/mapping_results.txt
mkdir -p ./ddbs_1_data ./ddbs_2_data ./dfs_1_data ./dfs_2_data
# Stop any running containers and remove volumes
echo "Stopping existing containers..."
docker-compose down -v
# Start services
echo "Starting docker services..."
docker-compose up -d
# Wait for services to be ready
echo "Waiting for services to initialize..."
sleep 5
# Clear databases and storage
echo "Clearing existing data..."
bash "$DB_SCRIPTS/mongo_drop.sh"
bash "$STORAGE_SCRIPTS/clear_storage.sh"
# Load initial data
echo "Loading initial data..."
python3 bulk_load_data.py
sleep 5
python3 post_bulk_load_data.py
# Generate additional data
echo "Generating additional data..."
docker exec -it python-app bash -c "cd /usr/src/app/ && python3 ./generate_beread.py"
docker exec -it python-app bash -c "cd /usr/src/app/ && python3 ./generate_popular_rank.py"
# Set up and load files
echo "Setting up file storage..."
docker cp "$STORAGE_SCRIPTS/bulk_load_file.sh" storage0:/etc/fdfs_buffer/
echo "Loading files into storage..."
docker exec -it storage0 bash -c "cd /etc/fdfs_buffer/ && bash ./bulk_load_file.sh"
# Update file paths
echo "Updating file paths..."
mv db-generation/articles/mapping_results.txt backend/mapping_results.txt
python3 ./update_file_path.py
echo "Initialization completed successfully at $(date)"