-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatcher_.sh
More file actions
executable file
·64 lines (56 loc) · 1.83 KB
/
Copy pathwatcher_.sh
File metadata and controls
executable file
·64 lines (56 loc) · 1.83 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
#!/bin/bash
# */1 * * * * cd ~/Dropbox/dev/tools/mediakit && /bin/bash watcher_.sh | /usr/sbin/rotatelogs -D -l -f logs/watcher.log.%Y-%m-%d 86400 >> ./logs/watcher_.log 2>&1
# /Users/nut/Dropbox/dev/tools/mediakit/watcher_.sh | /usr/sbin/rotatelogs -D -l -f /Users/nut/Dropbox/dev/tools/mediakit/logs/watcher.log.%Y-%m-%d 86400
export ENV="development"
export ENV="production"
echo $(date +"%Y-%m-%d %H:%M:%S:") "ENV: $ENV"
current_directory=$(dirname "$0")
echo "Current file path: $current_directory"
which pip
cd $current_directory
source .venv/bin/activate
function run_context() {
# Check if the script is already running
local name=$1
# echo "Checking if $name is running"
if pgrep -f "$name" > /dev/null
then
echo $(date +"%Y-%m-%d %H:%M:%S:") "ENV: $ENV": "$name is running" "PYTHON: $PYTHON"
exit 1
fi
}
current_file_name=$(basename $0)
run_context $current_file_name
CONFIG_FILE="var/folder.sh"
# CONDA_ENV="mediakit"
# PYTHON=$(which python)"
PYTHON=".venv/bin/python"
# eval $PYTHON cli compress -t video -f "./samples/zh.mp4"
function execute_command() {
run_context "ffmpeg"
run_context "ffprobe"
echo "Executing command: $PYTHON $1"
# echo "Executing command: $(date +"%Y-%m-%d %H:%M:%S:") $1"
# eval $PYTHON cli compress -t video -f $1 >> log/watcher.log 2>&1
eval $PYTHON cli compress -t video -w 1 -f \"$1\"
# result=$?
# echo "Result: $result"
return $? # Return the exit status of the last command
# eval $1
# return 1
}
# Read every line from a text file
# while IFS= read -r line
while read -u 10 line; do
# echo "$line"
# Skip empty lines
if [[ -z "$line" ]]; then
continue
fi
# Skip comments
# if [[ $line == "#"* ]]; then
if [[ $line == \#* ]]; then
continue
fi
execute_command "$line"
done 10<$CONFIG_FILE