summaryrefslogtreecommitdiffstats
path: root/stacks/lwip_stack/release/start_nstack.sh
blob: 35fe9dff24693cfd0924766577d386cf6f073139 (plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash


script_path=$(cd "$(dirname "$0")"; pwd)

. ${script_path}/script/nstack_var.sh
. ${script_path}/script/nstack_fun.sh

config_name=${script_path}/script/nstack_var.sh
if [ ! -e $config_name ]; then
    log $LINENO "nstack_var.sh not exit, plz check!"
    exit 1
fi

########################################################
##get the log info from the parameter of ./start -l XXX -a XXX ###
nstack_log_path=""
hostinfo_path=""
ARGS=`getopt -o "l:i:a:" -l "vdev:,file-prefix:,no-pci" -n "start_nstack.sh" -- "$@"`
eval set -- "${ARGS}"
while true
do
    case "$1" in
        -l)
            nstack_log_path="$2"
            shift 2
            ;;
        -i)
            hostinfo_path="$2"
            shift 2
            ;;
        --vdev)
            VDEV="--vdev=$2"
            shift 2
            ;;
        --file-prefix)
            FILE_PREFIX="--file-prefix=$2"
            shift 2
            ;;
        --no-pci)
            NO_PCI="--no-pci"
            shift 1
            ;;
        --)
            shift
            break
            ;;
        *)
            echo "Option illegal, please check input!"
            exit 1
            ;;
    esac
done

hostinfo_stat=0

(
flock -e -n 200
if [ $? -eq 1 ]
then
    log $LINENO "another process is running now, exit"
    exit 1
fi

########################################################
# modify the nstack & dpdk log path config: nStackConfig.json
if [ -n "$nstack_log_path" ]; then
    modify_nstack_log_path $nstack_log_path
fi

if [ -n "$hostinfo_path" -a -e  "$hostinfo_path" -a -r "$hostinfo_path" ]; then
    nstack_alarm_local_ip=($(awk -F '=' '/\['AGENT'\]/{a=1}a==1&&$1"="~/^(\s*)(VM_ID)(\s*)(=)/{print $2 ;exit}' $hostinfo_path))
	modify_local_ip_env
else
    hostinfo_stat=1
fi


########################################################
#set the log path in nstack_var.sh#####
modify_log_var
) 200>>./lockfile

if [ -f "lockfile" ]; then
    rm lockfile
fi

. ${script_path}/script/nstack_var.sh


########################################################
# init_log_file:nstack.log and dpdk.log
# if need print log, the messgae need add after init_log_file
init_log_file

if [ "$hostinfo_stat"  -ne 0 ]; then
    log $LINENO "please use correct -i parameter for start_nstack.sh"
    log $LINENO "host info path:$hostinfo_path"
    hostinfo_stat=0
fi

log $LINENO "######################start nstack######################"

########################################################
# check application running
process_nstack_main=nStackMain

pid_nstack=`pidof $process_nstack_main`

nstack_ctrl_path=${script_path}/bin

pgrep nStackMain
main_run_status=$?
if [ ${main_run_status} -eq 0 ]; then
        log $LINENO "nStackMain is running ok, please stop it first!"
        save_pid_file ${pid_master}
        exit 0
fi

huge_files=`ls /mnt/nstackhuge`
if [ "x${huge_files}" != "x" ]
then
	if [ "x${pid_nstack}" = "x" ]
	then
		log $LINENO "huge page file exist and nStackMain not exist"
		exit 1
	fi
fi


########################################################
# set hugepage
init_hugepage $process_nstack_main


########################################################
# install config
install_config

########################################################
core_mask=1
START_TYPE="primary"
log $LINENO "./script/run_nstack_main.sh ${core_mask} $HUGE_DIR $MEM_SIZE $START_TYPE $VDEV $NO_PCI"
${script_path}/script/run_nstack_main.sh $HUGE_DIR $MEM_SIZE $VDEV $NO_PCI

print_pid=$(ps -ux | grep nStackMain | awk '{print $2}' | awk 'NR == 2')
echo "nStackMain PID:$print_pid"
log $LINENO "nstack start success"
exit 0