summaryrefslogtreecommitdiffstats
path: root/stacks/lwip_stack/release/start_nstack.sh
blob: db0c084ebe9432fe95d7fc5b5ca1003e69201780 (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
#!/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=""
while getopts "l:i:a:" arg
do
   case $arg in
   l)
      nstack_log_path="$OPTARG"
      ;;
   i)
      hostinfo_path="$OPTARG"
      ;;
   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"
${script_path}/script/run_nstack_main.sh $HUGE_DIR $MEM_SIZE

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