Added workers
This commit is contained in:
parent
0c44c92dab
commit
4132345e3d
6
config/app.sh
Normal file
6
config/app.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
# app config - loaded on server bootup
|
||||
# this example file will get overwritten with application-specific config
|
||||
|
||||
# worker_add <worker> <interval>
|
||||
# ---
|
||||
# worker_add example 5
|
6
http.sh
6
http.sh
|
@ -6,6 +6,12 @@ function ctrl_c() {
|
|||
echo -e "Killed all remaining processes.\nHave a great day!!"
|
||||
}
|
||||
|
||||
source src/worker.sh
|
||||
|
||||
if [[ -f "config/app.sh" ]]; then
|
||||
source config/app.sh
|
||||
fi
|
||||
|
||||
source config/master.sh
|
||||
echo "HTTP.sh"
|
||||
|
||||
|
|
22
src/worker.sh
Executable file
22
src/worker.sh
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
# worker.sh - setup and control of workers
|
||||
|
||||
# worker_add(name, interval)
|
||||
function worker_add() {
|
||||
if [[ -x "workers/$1/worker.sh" ]]; then
|
||||
while true; do workers/$1/worker.sh; sleep $2; if [[ $(cat workers/$1/control) == "die" ]]; then echo "" > workers/$1/control; while true; do if [[ $(cat workers/$1/control) == "run" ]]; then echo "" > workers/$1/control; break; fi; sleep $2; done; fi; done &
|
||||
else
|
||||
echo "You have a broken worker configuration! Please check if worker.sh in worker $1 is executable."
|
||||
fi
|
||||
}
|
||||
|
||||
# worker_kill(name)
|
||||
function worker_kill() {
|
||||
echo "die" > workers/$1/control
|
||||
}
|
||||
|
||||
# worker_resume(name)
|
||||
function worker_resume() {
|
||||
echo "run" > workers/$i/control
|
||||
}
|
1
workers/example/control
Normal file
1
workers/example/control
Normal file
|
@ -0,0 +1 @@
|
|||
|
2
workers/example/worker.sh
Executable file
2
workers/example/worker.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
date
|
Loading…
Reference in a new issue