Blame view

setup.sh 2.55 KB
115047ee   tangwang   为一个租户灌入测试数据;实例的启动...
1
2
  #!/bin/bash
  
2a76641e   tangwang   config
3
4
  source /home/tw/miniconda3/etc/profile.d/conda.sh
  
115047ee   tangwang   为一个租户灌入测试数据;实例的启动...
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  # SearchEngine Setup and Startup Script
  # This script sets up the environment and starts all services
  
  set -e  # Exit on error
  
  # Colors for output
  RED='\033[0;31m'
  GREEN='\033[0;32m'
  YELLOW='\033[1;33m'
  NC='\033[0m' # No Color
  
  echo -e "${GREEN}========================================${NC}"
  echo -e "${GREEN}SearchEngine Setup Script${NC}"
  echo -e "${GREEN}========================================${NC}"
  
  # Change to project directory
  cd "$(dirname "$0")"
  PROJECT_ROOT=$(pwd)
  
  echo -e "\n${YELLOW}Step 1: Setting up Conda environment${NC}"
  # Check if conda is available
  if ! command -v conda &> /dev/null; then
      echo -e "${RED}Error: conda not found. Please install Miniconda or Anaconda${NC}"
      exit 1
  fi
  
  # Source conda
  source /home/tw/miniconda3/etc/profile.d/conda.sh
  
  # Check if environment exists
  if conda env list | grep -q "searchengine"; then
      echo -e "${GREEN}Environment 'searchengine' already exists${NC}"
      conda activate searchengine
  else
      echo -e "${YELLOW}Creating conda environment 'searchengine'...${NC}"
      conda env create -f environment.yml
      conda activate searchengine
      echo -e "${GREEN}Environment created successfully!${NC}"
  fi
  
  # Verify environment
  echo -e "\n${YELLOW}Current Python version:${NC}"
  python --version
  
  echo -e "\n${YELLOW}Step 2: Loading configuration${NC}"
  # Check if .env exists
  if [ ! -f ".env" ]; then
      echo -e "${YELLOW}Creating .env from .env.example...${NC}"
      cp .env.example .env
      echo -e "${GREEN}.env file created. Please update it with your actual configuration.${NC}"
  fi
  
  # Display configuration
  echo -e "${GREEN}Configuration loaded:${NC}"
  python -c "from config.env_config import print_config; print_config()"
  
  echo -e "\n${YELLOW}Step 3: Checking Elasticsearch connection${NC}"
  python -c "
  from config.env_config import get_es_config
  from utils.es_client import ESClient
  es_config = get_es_config()
  client = ESClient(hosts=[es_config['host']], username=es_config.get('username'), password=es_config.get('password'))
  if client.ping():
      print('✓ Elasticsearch is reachable')
  else:
      print('✗ Elasticsearch connection failed')
      exit(1)
  "
  
  echo -e "\n${GREEN}========================================${NC}"
  echo -e "${GREEN}Setup Complete!${NC}"
  echo -e "${GREEN}========================================${NC}"
  echo ""
  echo -e "Next steps:"
  echo -e "  1. Ingest data: ${YELLOW}./scripts/ingest.sh${NC}"
  echo -e "  2. Start backend: ${YELLOW}./scripts/start_backend.sh${NC}"
  echo -e "  3. Start frontend: ${YELLOW}./scripts/start_frontend.sh${NC}"
  echo ""