2017-04-21 10:43:26 +00:00
|
|
|
#!/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"
|
2017-08-25 07:11:21 +00:00
|
|
|
echo " -o [N] Other ARGs for app"
|
2017-04-21 10:43:26 +00:00
|
|
|
echo " -h show this help"
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
conf=config.ini
|
|
|
|
bin=./example/helloworld
|
|
|
|
|
2017-08-25 07:11:21 +00:00
|
|
|
while getopts "c:b:o:h" args
|
2017-04-21 10:43:26 +00:00
|
|
|
do
|
|
|
|
case $args in
|
|
|
|
c)
|
|
|
|
conf=$OPTARG
|
|
|
|
;;
|
|
|
|
b)
|
|
|
|
bin=$OPTARG
|
|
|
|
;;
|
2017-08-25 07:11:21 +00:00
|
|
|
o)
|
|
|
|
others=$OPTARG
|
|
|
|
;;
|
2017-04-21 10:43:26 +00:00
|
|
|
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++));
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2017-08-08 14:36:49 +00:00
|
|
|
for((proc_id=0; proc_id<${num_procs}; ++proc_id))
|
2017-04-21 10:43:26 +00:00
|
|
|
do
|
2017-08-08 14:36:49 +00:00
|
|
|
if ((proc_id == 0))
|
2017-04-21 10:43:26 +00:00
|
|
|
then
|
2017-08-25 07:11:21 +00:00
|
|
|
echo "${bin} --conf ${conf} --proc-type=primary --proc-id=${proc_id} ${others}"
|
|
|
|
${bin} --conf ${conf} --proc-type=primary --proc-id=${proc_id} ${others} &
|
2017-08-08 14:36:49 +00:00
|
|
|
sleep 5
|
|
|
|
else
|
2017-08-25 07:11:21 +00:00
|
|
|
echo "${bin} --conf ${conf} --proc-type=secondary --proc-id=${proc_id} ${others}"
|
|
|
|
${bin} --conf ${conf} --proc-type=secondary --proc-id=${proc_id} ${others} &
|
2017-08-08 14:36:49 +00:00
|
|
|
fi
|
2017-04-21 10:43:26 +00:00
|
|
|
done
|