forked from F-Stack/f-stack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
67 lines (61 loc) · 1.59 KB
/
start.sh
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
67
#!/bin/bash
function usage() {
echo "F-Stack app start tool"
echo "Options:"
echo " -c [conf] Path of config file"
echo " -b [N] Path of binary"
echo " -h show this help"
exit
}
conf=config.ini
bin=./example/helloworld
while getopts "c:b:h" args
do
case $args in
c)
conf=$OPTARG
;;
b)
bin=$OPTARG
;;
h)
usage
exit 0
;;
esac
done
allcmask0x=`cat ${conf}|grep lcore_mask|awk -F '=' '{print $2}'`
((allcmask=16#$allcmask0x))
num_procs=0
PROCESSOR=$(grep 'processor' /proc/cpuinfo |sort |uniq |wc -l)
for((i=0;i<${PROCESSOR};++i))
do
mask=`echo "2^$i"|bc`
((result=${allcmask} & ${mask}))
if [ ${result} != 0 ]
then
((num_procs++));
cpuinfo[$i]=1
else
cpuinfo[$i]=0
fi
done
proc_id=0
for((i=0;i<${PROCESSOR};++i))
do
if ((cpuinfo[$i] == 1))
then
cmask=`echo "2^$i"|bc`
cmask=`echo "obase=16;${cmask}"|bc`
if ((proc_id == 0))
then
echo "${bin} ${conf} -c $cmask --proc-type=primary --num-procs=${num_procs} --proc-id=${proc_id}"
${bin} ${conf} -c ${cmask} --proc-type=primary --num-procs=${num_procs} --proc-id=${proc_id} &
sleep 5
else
echo "${bin} ${conf} -c $cmask --proc-type=secondary --num-procs=${num_procs} --proc-id=${proc_id}"
${bin} ${conf} -c $cmask --proc-type=secondary --num-procs=${num_procs} --proc-id=${proc_id} &
fi
((proc_id++))
fi
done