xref: /f-stack/start.sh (revision a7b42f3d)
1#!/bin/bash
2
3function usage() {
4    echo "F-Stack app start tool"
5    echo "Options:"
6    echo " -c [conf]                Path of config file"
7    echo " -b [N]                   Path of binary"
8    echo " -o [N]                   Other ARGs for app"
9    echo " -h                       show this help"
10    exit
11}
12
13conf=config.ini
14bin=./example/helloworld
15
16while getopts "c:b:o:h" args
17do
18    case $args in
19         c)
20            conf=$OPTARG
21            ;;
22         b)
23            bin=$OPTARG
24            ;;
25         o)
26            others=$OPTARG
27            ;;
28         h)
29            usage
30            exit 0
31            ;;
32    esac
33done
34
35allcmask0x=`cat ${conf}|grep lcore_mask|awk -F '=' '{print $2}'`
36((allcmask=16#$allcmask0x))
37
38num_procs=0
39PROCESSOR=$(grep 'processor' /proc/cpuinfo |sort |uniq |wc -l)
40for((i=0;i<${PROCESSOR};++i))
41do
42    mask=`echo "2^$i"|bc`
43    ((result=${allcmask} & ${mask}))
44    if [ ${result} != 0 ]
45    then
46        ((num_procs++));
47    fi
48done
49
50for((proc_id=0; proc_id<${num_procs}; ++proc_id))
51do
52    if ((proc_id == 0))
53    then
54        echo "${bin} --conf ${conf} --proc-type=primary --proc-id=${proc_id} ${others}"
55        ${bin} --conf ${conf} --proc-type=primary --proc-id=${proc_id} ${others} &
56        sleep 5
57    else
58        echo "${bin} --conf ${conf} --proc-type=secondary --proc-id=${proc_id} ${others}"
59        ${bin} --conf ${conf} --proc-type=secondary --proc-id=${proc_id} ${others} &
60    fi
61done
62