blob: f07d807e66401d904df09dae03b1c3a2caa9c902 (
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
|
#!/bin/sh
export PATH=/bin:/usr/bin:/sbin
if [ "$UID" = "0" ] ; then
echo '**** WARNING **** Do not start this script as ROOT !!!'
echo 'Please, interrupt me! Otherwise I continue in 30 sec.'
sleep 30
fi
h=`pwd`
home=$h/home
export TIMEFORMAT=' elapsed time: %R'
export NINIT_HOME=$home
cstart='' ; cend='' ; bad=''
tty -s 2>/dev/null
if [ $? -eq 0 ] ; then
# 30=black 31=red 32=green 33=yellow 34=blue ... 37=white
# 40=black 41=red ... backgrownd color
cstart='[1;47m[1;30m' ; cend='[0;39m'; bad='[1;44m[1;31m'
fi
echo ' starting server' $cstart$h/ninit -H$home$cend
echo ' wait for this test more than 25 seconds'
echo ' no PANIC! the test terminates in 92 sec always'
echo
start_time=`date +%s`
print_env () {
if [ -f /proc/$ninit_pid/environ ] ; then
echo
echo ' '$1 $cstart \
`./sleeprun -a4 tr '\000' ' ' < /proc/$ninit_pid/environ` $cend
fi
}
do_it () {
X=$1; shift
echo ' starting '$cstart$@$cend' #' $X
./sleeprun -a20 $@
ret=$?
if [ $ret -ne 0 ] ; then
echo $bad'***** WARNING *****'$cend
echo 'Exit status of' $cstart$@$cend is $ret
sleep 3
fi
return $ret
}
do_it '(install HOME)' ./install-bin home < misc/HOME || exit 1
test -f home/env/run || gzip -dc home.tar.gz | do_it '(unpack home)' tar -xv
args="./sleeprun -a90 ./env -i NINIT_TIME=empty $h/ninit -H$home"
echo ' starting' $cstart$args$cend
$args &
ninit_pid=$!
echo ' ninit PID='$cstart$ninit_pid$cend
do_it '(waiting the ninit to start)' sleep 1
do_it '(list)' ./nsvc -L
time do_it '(wait 4s env)' ./nsvc -W4 env
do_it '(once)' ./nsvc -o sleep
do_it '(set respawning mode)' ./nsvc -R sleep
do_it '(list)' ./nsvc -L
sleep 1
do_it '(diagnostic)' ./nsvc sleep ; echo
do_it '(list)' ./nsvc -L
do_it '(list pids)' ./nsvc -g sleep default
do_it '(history)' ./nsvc -H
echo ; echo ' reloading ninit'
after=after-reload
do_it '' ps uwwww -p $ninit_pid ; echo
do_it '' ln -sf ninit $after
print_env 'old ninit environ:'
current_time=`date +%s`
args="./reload -v -a 20 -eNINIT_TIME=$current_time -e Hello=world"
args="$args -eYou_are=$USER -u $h/$after -H$home"
echo ' starting' $cstart$args$cend
time ./sleeprun -a30 $args
print_env 'new ninit environ:'
do_it '(sleep 4+3 sec; stopping do_update mode)' sleep 4
do_it '' ps uwwww -p $ninit_pid ; echo
do_it '' sleep 3
echo
time do_it 'sync mode (max 3 sec)' ./nsvc -o S
do_it '(list)' ./nsvc -L
all=`./nsvc -L`
do_it '(remove cron flags)' ./nsvc -K0 $all
do_it '(down all services)' ./nsvc -d $all
time do_it '(wait 1s all to finish)' ./nsvc -W1 $all
do_it '(list)' ./nsvc -L
do_it '(memory usage)' ./nsvc -D
do_it '(depends)' ./nsvc -D default
[ -f /proc/$ninit_pid/statm ] && \
do_it '(ninit daemon)' cat /proc/$ninit_pid/statm
do_it '(kill ninit daemon)' kill $ninit_pid
wait
end_time=`date +%s`
./sleeprun -a4 rm -f $after
n=`expr $end_time - $start_time` ; echo
echo ' test continues:' $cstart$n sec$cend
echo
echo $cstart' Creating services in ./etc/ninit - Demo '$cend
do_it '(clean old ./etc/)' rm -r -f ./etc
do_it '(install ./etc/ninit/)' ./install-bin . < misc/ETC
do_it '(converter)' ./inittab /etc/inittab etc/ninit services.sh > /dev/null
do_it '(making services - demo)' ./services.sh
# do_it '' ls -F ./etc/ninit
echo
echo Look now at $cstart./services.sh$cend and $cstart./etc/ninit/$cend.
echo
|