evristzam / ndt

Automatically exported from code.google.com/p/ndt
Other
0 stars 0 forks source link

Change NDT init script to use $PATH variable when counting numer of running processes #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A User writes:

----

Hi,

Problem that had me scratching my head for a while, with fix:

web100srv wouldn't start:
===
[root@ndt init.d]# ./ndt restart
Stopping web100srv:                                        [FAILED]
Stopping fakewww:                                          [  OK  ]
Starting fakewww:                                          [  OK  ]
===

Nothing in logs etc etc

Digging deeper
===
[root@ndt init.d]# sh -x ./ndt start
...
+ start_web100srv
++ ps auxw
++ grep web100srv
++ grep -v grep
++ wc -l
+ cnt=1
+ '[' 1 = 0 ']'
+ start_fakewww
+ '[' '!' 1 = 0 ']'
++ ps auxw
++ grep fakewww
++ grep -v grep
++ wc -l
+ cnt=0
+ '[' 0 = 0 ']'
+ echo -n 'Starting fakewww:'
Starting fakewww:+ /usr/sbin/fakewww -f /index.html -s -l 
/var/log/ndt/fakewww_access.log -e /var/log/ndt/fakewww_error.log
+ RETVAL=0
...
===
It doesn't even try to start web100srv

===
[root@ndt init.d]# ps auxw | grep web100srv
root      6930  0.0  0.0   3824   536 ?        S    Apr12   0:00 tail -f 
/var/log/ndt/web100srv.log
root     20412  0.0  0.0   4020   712 pts/1    R+   16:15   0:00 grep web100srv
===

Because I was doing a tail on web100srv.log, the web100srv program itself 
couldn't be restarted!
Heisenberg strikes again !!

Change the greps in /etc/init.d/ndt to include the bin path
===
   cnt=`ps auxw | grep $path/web100srv | grep -v grep | wc -l`
   cnt=`ps auxw | grep $path/fakewww | grep -v grep | wc -l`
===
and you can now tail the log file and restart the server
===
[root@ndt init.d]# tail -f /var/log/ndt/web100srv.log &
[1] 20829
[root@ndt init.d]# Web100srv (ver 3.4.4a) process (20438) started May 17 
16:17:12
May 17 16:18:11  150.101.154.1 port 34448
spds[0] = '  0 0 653 773 0 8 0 0 0 0 8 0 1.61 0 0 0 1 0' max=773 [53.91%]
spds[1] = '  0 0 305 335 2 5 0 0 0 0 218 0 1.28 6 7 852 0 218' max=335 [51.78%]
spds[2] = '  0 0 14 4371 1719 8 10 36 290 5862 2 0 7.24 0 0 0 1 0' max=5862 
[47.62%]
spds[3] = '  0 0 12 613 5412 26 4 0 2 0 237 0 14.46 161 16 6129 0 237' max=5412 
[89.17%]
May 17 
16:18:11,150.101.154.1,481,12859,1487,0,430023,6070,16,2,12313,0,1408,237,6306,4
67456,33554432,235136,209562,10649314,67794,17730720,10,11,1,116864,297,467456,0
,0,0,0,1,3,3,9,4,2,12313,45,13,22,5750,0,126,0,-1208958976,3,0,248,0,6951008,281
6,235136,2
Web100srv (ver 3.4.4a) process (20816) started May 17 16:36:25

[root@ndt init.d]# ./ndt restart
Stopping web100srv:                                        [  OK  ]
Stopping fakewww:                                          [  OK  ]
Starting web100srv:                                        [  OK  ]
Starting fakewww:                                          [  OK  ]
[root@ndt init.d]# Web100srv (ver 3.4.4a) process (20845) started May 17 
16:36:49
===

Original issue reported on code.google.com by jwzuraw...@gmail.com on 17 May 2011 at 11:16

GoogleCodeExporter commented 9 years ago
Fix committed in r394.  

Original comment by jwzuraw...@gmail.com on 17 May 2011 at 11:24