-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.sh
More file actions
executable file
·68 lines (50 loc) · 1.74 KB
/
Copy pathstart.sh
File metadata and controls
executable file
·68 lines (50 loc) · 1.74 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
62
63
64
65
66
#!/bin/bash
APP_PID_FILE="app.pid"
LISTENER_PID_FILE="listener.pid"
WORKER_PID_FIRE="worker.pid"
LOG_FILE="app_start.log"
# --------------------------------
# Create a virtual environment if it doesn't exist
if [ ! -d "venv" ]; then
echo "Creating virtual environment..."
python3 -m venv venv
fi
#!/bin/bash
# Activate virtual environment
source venv/bin/activate
# Clear old log files
echo "Clearing old log files..."
rm -f app.log app_start.log listener.log worker.log
echo "Logs cleared."
# Install dependencies
echo "Installing dependencies..."
pip install -r requirements.txt
echo "Starting TeleFileDB..." | tee -a $LOG_FILE
# Start the Flask web application in the background
if [ -f $APP_PID_FILE ]; then
echo "Web application is already running." | tee -a $LOG_FILE
else
nohup python3 app.py > app.log 2>&1 &
APP_PID=$!
echo $APP_PID > $APP_PID_FILE
echo "Web application started. PID: $APP_PID. Log file: app.log" | tee -a $LOG_FILE
fi
# Start the Telegram listener in the background
if [ -f $LISTENER_PID_FILE ]; then
echo "Telegram listener is already running." | tee -a $LOG_FILE
else
nohup python3 run_listener.py > listener.log 2>&1 &
LISTENER_PID=$!
echo $LISTENER_PID > $LISTENER_PID_FILE
echo "Telegram listener started. PID: $LISTENER_PID. Log file: listener.log" | tee -a $LOG_FILE
fi
# Start the Telegram worker in the background
if [ -f $WORKER_PID_FIRE ]; then
echo "Telegram worker is already running." | tee -a $LOG_FILE
else
nohup python3 upload_worker.py > worker.log 2>&1 &
WORKER_PID=$!
echo $WORKER_PID > $WORKER_PID_FIRE
echo "Telegram worker started. PID: $WORKER_PID. Log file: worker.log" | tee -a $LOG_FILE
fi
echo "TeleFileDB startup complete." | tee -a $LOG_FILE