Author |
Message |
Robert Lope #1 / 9
|
 desperate: perl scripts called from init.d/... scripts
With respect to the runlevel changing scripts such as in /etc/init.d on some systems and in /sbin/init.d on other systems: If run level start/stop scripts, written in posix shell, start and stop other scripts written in perl is there any reason to expect problems? in general? in HP-UX 11? All the scripts I moved from an older Solaris system and from an older HP-UX 10.20 to a new HP-UX 11 cluster are having various mysterious problems. That the scripts and perl are in place before they are run has been confirmed for both moving up in run levels and in moving down in run levels. The scripts work perfectly when run by root manually by running them directly and via the run level links. eg: cd /sbin/init.d; ./script.pl start_msg < -- works cd /sbin/init.d; ./script.pl start < -- works cd /sbin/init.d; ./script.pl stop_msg < -- works cd /sbin/init.d; ./script.pl stop_msg < -- works cd /sbin/rc2.d; ./K96script.pl .... < -- works cd /sbin/rc3.d; ./S96script.pl .... < -- works The problems include: When the system is actually changing run levels and the init process executes the scripts they fail to stop on going down run levels. When the system is actually changing run levels and the init process executes the scripts they fork off another process when going up run levels. eg: dba 19000 1 10 00:07:01 ... /bin/sh /dba/dbscripts/loadall /dba/cfg/cfg21 dba 19005 1900 4 00:07:01 ... /bin/sh /dba/dbscripts/loadall /dba/cfg/cfg21 The posix scripts are owned by root. The database control scripts written in perl are owned by dba. The posix scripts have lines like: su - dba -c /dba/dba/dbscripts/loadall /dba/cfg/cfg21& > /logs/dba/cfg21 2>&1 HP support rep thinks the problem is the use of perl. Any ideas? --
|
Mon, 19 Apr 2004 18:19:29 GMT |
|
 |
Clinton A. Pier #2 / 9
|
 desperate: perl scripts called from init.d/... scripts
On 01 Nov 2001 10:19:29 -0700, Robert Lopez Quote:
>With respect to the runlevel changing scripts such as in /etc/init.d >on some systems and in /sbin/init.d on other systems: >If run level start/stop scripts, written in posix shell, start and >stop other scripts written in perl is there any reason to expect >problems? in general? in HP-UX 11? > [...] >The scripts work perfectly when run by root manually by running them >directly and via the run level links. > [...] >The problems include:
The places to look are: * Missing pieces of the environment (PATH, TERM, HOME, etc...) * Filehandles not open to expected places. Are you reading STDIN and it's connected to /dev/null? Or something that's not a tty? * Permissions/user environment are screwy. You say the init scripts aren't actually run by root in Real Life, but by a dba user? Can you su - to that user and run them okay? * Filesystems aren't all there yet. Perl's obviously there... are the appropriate module directories? For starters. -- Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
"If you rush a Miracle Man, for details, see http://geeksalad.org you get rotten Miracles." --Miracle Max, The Princess Bride
|
Mon, 19 Apr 2004 20:50:16 GMT |
|
 |
Richard J. Rauenza #3 / 9
|
 desperate: perl scripts called from init.d/... scripts
Quote:
>With respect to the runlevel changing scripts such as in /etc/init.d >on some systems and in /sbin/init.d on other systems: >If run level start/stop scripts, written in posix shell, start and >stop other scripts written in perl is there any reason to expect >problems? in general? in HP-UX 11?
I don't think so. The first rc script is /sbin/rc -- I didn't trace it, but I would expect it to just exec whatever it finds in /sbin/init.d/... [...] Quote: >The problems include: >When the system is actually changing run levels and the init process >executes the scripts they fail to stop on going down run levels.
I don't understand what you mean by the scripts fail to stop. The scripts never exit? Or the services that the scripts control don't stop? Quote: >When the system is actually changing run levels and the init process >executes the scripts they fork off another process when going up run >levels. > eg: >dba 19000 1 10 00:07:01 ... /bin/sh /dba/dbscripts/loadall /dba/cfg/cfg21 >dba 19005 1900 4 00:07:01 ... /bin/sh /dba/dbscripts/loadall /dba/cfg/cfg21
I don't have any idea what you're showing us above. Quote: >The posix scripts are owned by root. The database control scripts >written in perl are owned by dba. The posix scripts have lines like: > su - dba -c /dba/dba/dbscripts/loadall /dba/cfg/cfg21& > /logs/dba/cfg21 2>&1
So your init script _isn't_ written in perl? But rather sh, which calls a perl script? Quote: >HP support rep thinks the problem is the use of perl.
I hesitate to contradict a colleague, but my gut feeling is that it may have more to do with that su -- and possibly the receipt of a SIGHUP. That's a common problem, but usually only with daemons. I've seen other init scripts fail, though, when su is involved. What does /etc/rc.log say? And you may find better answers at comp.sys.hp.hpux.... Rich --
Technical Consultant | I speak for me, | 19055 Pruneridge Ave. Development Alliances Lab| *not* HP | MS 46TU2 ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
|
Mon, 19 Apr 2004 20:37:06 GMT |
|
 |
Darren Dunha #4 / 9
|
 desperate: perl scripts called from init.d/... scripts
Quote:
> The scripts work perfectly when run by root manually by running them > directly and via the run level links. > eg: > cd /sbin/init.d; ./script.pl start_msg < -- works > cd /sbin/init.d; ./script.pl start < -- works > cd /sbin/init.d; ./script.pl stop_msg < -- works > cd /sbin/init.d; ./script.pl stop_msg < -- works > cd /sbin/rc2.d; ./K96script.pl .... < -- works > cd /sbin/rc3.d; ./S96script.pl .... < -- works
Try running it the way rc2 will (on Solaris)... /sbin/sh /etc/rc2.d/K96script.pl < -- works? If that doesn't work (it shouldn't), then it won't work at startup. The script is not executed by rc2. The script is given to sh as an argument. If sh doesn't understand it, it won't work. Solution: Write a different script. /etc/rc2.d/S96script.pl #!/bin/sh /etc/init.d/someperlscript $1 --
Unix System Administrator Taos - The SysAdmin Company Got some Dr Pepper? San Francisco, CA bay area < How are you gentlemen!! Take off every '.SIG'!! >
|
Mon, 19 Apr 2004 22:05:32 GMT |
|
 |
Stuart Gal #5 / 9
|
 desperate: perl scripts called from init.d/... scripts
Quote: > su - dba -c /dba/dba/dbscripts/loadall /dba/cfg/cfg21& >
/logs/dba/cfg21 2>&1 Quote: > HP support rep thinks the problem is the use of perl. > Any ideas?
look at /sbin/rc2 to see what, if anything, wired is going on? -- Stuart Gall ------------------------------------------------ This message is not provable.
|
Mon, 19 Apr 2004 21:56:23 GMT |
|
 |
Robert Lope #6 / 9
|
 desperate: perl scripts called from init.d/... scripts
Quote:
> >With respect to the runlevel changing scripts such as in /etc/init.d > >on some systems and in /sbin/init.d on other systems: > >If run level start/stop scripts, written in posix shell, start and > >stop other scripts written in perl is there any reason to expect > >problems? in general? in HP-UX 11? > I don't think so. The first rc script is /sbin/rc -- I didn't trace it, > but I would expect it to just exec whatever it finds in /sbin/init.d/... > [...] > >The problems include: > >When the system is actually changing run levels and the init process > >executes the scripts they fail to stop on going down run levels. > I don't understand what you mean by the scripts fail to stop. The > scripts never exit? Or the services that the scripts control don't > stop?
I mean the /bin/sh program looks up the pid of the perl program and sends a signal to the perl program which it traps and then does an orderly shutdown. From a shell this always works. But some how it fails when init tries to tell it to shut down. The evidence is in the log file. It never logs a shutdown complete message. So it finally killed but not in an orderly fashion. Quote: > >When the system is actually changing run levels and the init process > >executes the scripts they fork off another process when going up run > >levels. > > eg: > >dba 19000 1 10 00:07:01 ... /bin/sh /dba/dbscripts/loadall /dba/cfg/cfg21 > >dba 19005 1900 4 00:07:01 ... /bin/sh /dba/dbscripts/loadall /dba/cfg/cfg21 > I don't have any idea what you're showing us above.
That is because I was trying to shorten a long line and took out an extra 0. The init (1) starts process 19000 and 19000 [1900 above] starts 19005. Quote: > >The posix scripts are owned by root. The database control scripts > >written in perl are owned by dba. The posix scripts have lines like: > > su - dba -c /dba/dba/dbscripts/loadall /dba/cfg/cfg21& > /logs/dba/cfg21 2>&1 > So your init script _isn't_ written in perl? But rather sh, which calls > a perl script?
Correct the /sbin/init.d/ script is written in posix shell are required by HP. It then starts a program written in perl, the /dba/dbscripts/loadall program above. [Again in hand typing I errored; one too many /dba] Quote: > >HP support rep thinks the problem is the use of perl. > I hesitate to contradict a colleague, but my gut feeling is that it may > have more to do with that su -- and possibly the receipt of a SIGHUP. > That's a common problem, but usually only with daemons. I've seen other > init scripts fail, though, when su is involved.
Do you recall how they were fixed? The object here is to have a reboot now (and ServiceGuard fail-over later) start all the data loading processes. The dba account can hand start them but we do not want to wait for the dba to hand start things. So we are trying to make the dba's tools do what they need to do in the dba's absence. We do the exact same thing with canned software like Informix and FlexLM and they do not have the problems. The EDS staff here says HP has told them that these packages know that su causes a forked process and they then kill off the first process. They say we must do the same in our perl scripts. Quote: > What does /etc/rc.log say?
The log says just what the posix shell tells it to say on startup; which is that the processes have started. I have never seen any shutdown messages in that log. I think the system must replace it when it begins to reboot. Quote: > And you may find better answers at comp.sys.hp.hpux....
I have addressed this issue there. I have as carefully as I know how to followed all of the advice. Quote: > Rich > --
> Technical Consultant | I speak for me, | 19055 Pruneridge Ave. > Development Alliances Lab| *not* HP | MS 46TU2 > ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
--
|
Mon, 19 Apr 2004 22:37:06 GMT |
|
 |
Robert Lope #7 / 9
|
 desperate: perl scripts called from init.d/... scripts
Quote:
> > The scripts work perfectly when run by root manually by running them > > directly and via the run level links. > > eg: > > cd /sbin/init.d; ./script.pl start_msg < -- works > > cd /sbin/init.d; ./script.pl start < -- works > > cd /sbin/init.d; ./script.pl stop_msg < -- works > > cd /sbin/init.d; ./script.pl stop_msg < -- works > > cd /sbin/rc2.d; ./K96script.pl .... < -- works > > cd /sbin/rc3.d; ./S96script.pl .... < -- works > Try running it the way rc2 will (on Solaris)... > /sbin/sh /etc/rc2.d/K96script.pl < -- works? > If that doesn't work (it shouldn't), then it won't work at startup. > The script is not executed by rc2. The script is given to sh as an > argument. If sh doesn't understand it, it won't work.
Ah! Ok. Quote: > Solution: > Write a different script. > /etc/rc2.d/S96script.pl > #!/bin/sh > /etc/init.d/someperlscript $1 > --
> Unix System Administrator Taos - The SysAdmin Company > Got some Dr Pepper? San Francisco, CA bay area > < How are you gentlemen!! Take off every '.SIG'!! >
Thanks! --
|
Tue, 20 Apr 2004 20:23:43 GMT |
|
 |
Robert Lope #8 / 9
|
 desperate: perl scripts called from init.d/... scripts
Quote:
> > su - dba -c /dba/dba/dbscripts/loadall /dba/cfg/cfg21& > > /logs/dba/cfg21 2>&1 > > HP support rep thinks the problem is the use of perl. > > Any ideas? > look at /sbin/rc2 to see what, if anything, wired is going on?
I do not understand this at all. Do you mean /sbin/rc2.d? By "wired" do you mean the soft-links? Quote: > -- > Stuart Gall > ------------------------------------------------ > This message is not provable.
--
|
Tue, 20 Apr 2004 20:25:55 GMT |
|
 |
Stuart Gal #9 / 9
|
 desperate: perl scripts called from init.d/... scripts
Quote:
> > > su - dba -c /dba/dba/dbscripts/loadall /dba/cfg/cfg21& > > > /logs/dba/cfg21 2>&1 > > > HP support rep thinks the problem is the use of perl. > > > Any ideas? > > look at /sbin/rc2 to see what, if anything, wired is going on? > I do not understand this at all. Do you mean /sbin/rc2.d? > By "wired" do you mean the soft-links?
OK, It has been a while since I worked on HPUX. IIRC The kernel calls /sbin/rcN when it changes to runlevel N /sbin/rcN then does some stuff and executes all the scripts in /sbin/rcN,d I do not mean "wired" like soft links I mean how exactly does HPUX call the init scripts, does it do anything odd that might affect the perl (phew got it in) scripts. Have they changed it in this version My email address is valid, just leave the stuart gall in to avoid being filtered. Perhaps we should continue this by email. -- Stuart Gall ------------------------------------------------ This message is not provable.
|
Tue, 20 Apr 2004 22:51:52 GMT |
|
|