LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 02-03-2009, 08:42 PM   #1
geek745
Member
 
Registered: Jul 2004
Location: Boston, MA
Distribution: Slackware; Ubuntu; Slax
Posts: 172
Blog Entries: 2

Rep: Reputation: 33
rc.httpd and rc.mysqld break startup scripts


Hello fellow slackers,

On my SW12.1 box I am trying to get both httpd and mysqld to startup on boot. However, they are mutually destructive with respect to their startup routines. And it does not matter whether I have them listed in rc.inet2 or rc.M or rc.local - either way the first guy will kill the rest of the startup chain.

Both scripts have
Code:
exit 1
and
Code:
exit 0
lines in them, and even if rc.M called rc.inet2, which contained either one (or both) of the scripts, it would ultimately exit rc.M, and then init will call rc.4 and send me to KDE. Looking back at the logs, any startup scripts called after rc.httpd or rc.mysqld fail to run.

My initial thought was to comment out the various exit statements in both scripts. This proves to be fishy business because rather than exiting prematurely on an error (or success), the script continues to chew through its remaining lines, which screws things up.

The thought just occurred to me (writing this during a MIPS assembly language class talking about jumps and such) that I should probably create a label at the end of the file and rather than exit, just "jump to the end." I'll try this later, but hopefully this is the end of the line for me. I haven't had this problem before on my LAMP setups, so I wonder a bit if it should be this much work... any thoughts appreciated.
 
Old 02-03-2009, 09:33 PM   #2
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,770

Rep: Reputation: 601Reputation: 601Reputation: 601Reputation: 601Reputation: 601Reputation: 601
Is MySQL initialized?

Rather than being 'mutually destructive' it sounds more like MySQL has not been initialized yet. Did you run mysql_install_db or otherwise set up the initial database?

See the comments at top of /etc/rc.d/rc.mysqld.

If you have already done this how about a little more info on your setup.
 
Old 02-03-2009, 10:39 PM   #3
XGizzmo
Member
 
Registered: Mar 2007
Distribution: Slackware
Posts: 264

Rep: Reputation: 68
Nether rc.httpd or rc.mysqld have any exit in them and both of them are already sourced from rc.M.
All you have to do is make the rc.* files executable and they will be ran. As far as the exit making
the parent script end it depends on if it was sourced into the calling script or if it was "ran" and
how the shell has been configured.
 
Old 02-04-2009, 01:25 AM   #4
geek745
Member
 
Registered: Jul 2004
Location: Boston, MA
Distribution: Slackware; Ubuntu; Slax
Posts: 172
Blog Entries: 2

Original Poster
Rep: Reputation: 33
the last lines of /etc/rc.d/rc.M:
Code:
# Start the MySQL database:
if [ -x /etc/rc.d/rc.mysqld ]; then
  . /etc/rc.d/rc.mysqld start
fi

# Start Apache web server:
if [ -x /etc/rc.d/rc.httpd ]; then
  . /etc/rc.d/rc.httpd start
fi

# Start the local setup procedure.
if [ -x /etc/rc.d/rc.local ]; then
  echo "Running rc.local:"
  . /etc/rc.d/rc.local
fi
I attached my complete rc.httpd (which calls apachectl, also attached) and rc.mysqld, in their original state.

XGizzmo, you were suggesting that if I replaced the line that said
Code:
  . /etc/rc.d/rc.httpd start
with
Code:
/bin/sh /etc/rc.d/rc.httpd start
that it might work correctly?
Attached Files
File Type: txt apachectl.txt (3.4 KB, 2 views)
File Type: txt rc.httpd.txt (379 Bytes, 3 views)
File Type: txt rc.mysqld.txt (11.8 KB, 18 views)
 
Old 02-04-2009, 01:35 AM   #5
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,770

Rep: Reputation: 601Reputation: 601Reputation: 601Reputation: 601Reputation: 601Reputation: 601
What do you get if you try to start mysql after you boot?

As root, (assuming /etc/rc.d/rc.mysqld is executable)

Code:
/etc/rc.d/rc.mysqld start
...what messages do you get?
 
Old 02-04-2009, 01:45 AM   #6
geek745
Member
 
Registered: Jul 2004
Location: Boston, MA
Distribution: Slackware; Ubuntu; Slax
Posts: 172
Blog Entries: 2

Original Poster
Rep: Reputation: 33
Each script starts its respective server on its own with no errors - works beautifully, it's just that anything I try to start after them (including the other one) is screwed.

For your amusement, this is what I get (just now):
Code:
xxx@xxx:xxx$ sudo /etc/rc.d/rc.mysqld start
Starting MySQL SUCCESS!
xxx@xxx:xxx$ sudo /etc/rc.d/rc.httpd start
Starting Apache...
xxx@xxx:xxx$
No errors! Just as it is, when my machine booted today, the last two lines of init's output were:
Code:
Starting MySQL. SUCCESS!
Starting up X11 session manager...
And I believe it to be the fact that rc.mysqld contains the line "exit 0" and rc.httpd (in apachectl) contains the statement "exit $ERROR_CODE" which is effectively "exit 0" at runtime that causes my troubles.

I moved the two server startup blocks to rc.local for testing just now, and changed the ". " invocation to a full "/bin/sh" invocation, hoping for a forked shell that can absorb the extra "exit" and return to hit the next one the same way:
Code:
# Start the MySQL database:
if [ -x /etc/rc.d/rc.mysqld ]; then
  /bin/sh /etc/rc.d/rc.mysqld start
fi

# Start Apache web server:
if [ -x /etc/rc.d/rc.httpd ]; then
  /bin/sh /etc/rc.d/rc.httpd start
fi
and voila - it works:
Code:
xxx@xxx:/etc/rc.d$ sudo ./rc.local
Starting MySQL SUCCESS!
Starting Apache...
httpd (pid 6163) already running
xxx@xxx:/etc/rc.d$
Thanks for all the pointers!
 
Old 02-04-2009, 02:03 AM   #7
astrogeek
Senior Member
 
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.1, 14.1, 64-14.1, -current, FreeBSD-10
Posts: 1,770

Rep: Reputation: 601Reputation: 601Reputation: 601Reputation: 601Reputation: 601Reputation: 601
Quote:
Originally Posted by geek745 View Post
For your amusement, this is what I get (just now):
Code:
xxx@xxx:xxx$ sudo /etc/rc.d/rc.mysqld start
Starting MySQL SUCCESS!
xxx@xxx:xxx$ sudo /etc/rc.d/rc.httpd start
Starting Apache...
xxx@xxx:xxx$
I usually like being amused , thanks. I just wanted to be sure MySQL had been initialized as I did not get that from the original post.

Anyway, glad you got it going.
 
Old 02-04-2009, 03:31 AM   #8
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,232

Rep: Reputation: Disabled
Quote:
Originally Posted by geek745 View Post
Hello fellow slackers,

On my SW12.1 box I am trying to get both httpd and mysqld to startup on boot. However, they are mutually destructive with respect to their startup routines. And it does not matter whether I have them listed in rc.inet2 or rc.M or rc.local - either way the first guy will kill the rest of the startup chain.

Both scripts have
Code:
exit 1
and
Code:
exit 0
lines in them, and even if rc.M called rc.inet2, which contained either one (or both) of the scripts, it would ultimately exit rc.M, and then init will call rc.4 and send me to KDE. Looking back at the logs, any startup scripts called after rc.httpd or rc.mysqld fail to run.
Your problem is the fact that you are not using Slackware rc scripts. Both your rc.mysql and rc.httpd are scripts from another source. The official Slackware scripts do not have "exit" statements because they are sourced from rc.M ... the "exit" in rc.mysql causes the rc.M script to exit as well due to the source command used to include rc.mysql in rc.M .

Is there a reason why you are not using Slackware's scripts?

Eric
 
Old 02-04-2009, 08:32 AM   #9
GazL
Senior Member
 
Registered: May 2008
Posts: 3,380

Rep: Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912
A quick perusal of rc.M seems to show some of the called subsystem rc scripts are sourced in and some are called with their own shell process..

Wouldn't it just be better to spawn new shells for all of the subsystem scripts and reduce the chance of possible cross contamination or other errors from customised subsystem scripts?

Though sourcing as much as possible may provide some small performance gain during startup, wouldn't the consistency and resilience of spawning a new shell for each of them be worth any additional cost in overhead?
 
Old 02-04-2009, 10:17 AM   #10
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,014

Rep: Reputation: 146Reputation: 146
Quote:
Originally Posted by GazL View Post
Though sourcing as much as possible may provide some small performance gain during startup, wouldn't the consistency and resilience of spawning a new shell for each of them be worth any additional cost in overhead?
Highly agree.
 
Old 02-05-2009, 11:03 PM   #11
geek745
Member
 
Registered: Jul 2004
Location: Boston, MA
Distribution: Slackware; Ubuntu; Slax
Posts: 172
Blog Entries: 2

Original Poster
Rep: Reputation: 33
AlienBob:

rc.mysqld is a symlink to /usr/local/share/mysql/mysql.server, which is the provided shell script for starting the mysql server, and is init-script-compliant (rc.mysqld start works) except for the fact that it exits. Thus it is not an official Slackware script.

rc.httpd I believe I wrote myself, following the example of other basic init scripts using the simple Bash case...esac structure. This calls apachectl, as you have seen, and that is where the exit occurs.

GazL:

I did not write the remainder of rc.M - the default behavior was to source all subsequent rc scripts as they were - I see now that this may be the safest procedure...
 
Old 02-06-2009, 04:24 AM   #12
guanx
Senior Member
 
Registered: Dec 2008
Posts: 1,014

Rep: Reputation: 146Reputation: 146
Quote:
Originally Posted by geek745 View Post
I did not write the remainder of rc.M - the default behavior was to source all subsequent rc scripts as they were - I see now that this may be the safest procedure...
Excuse me, but do you mean source-ing the scripts is safer than sh-ing them?

Last edited by guanx; 02-06-2009 at 04:30 AM.
 
Old 02-06-2009, 05:58 AM   #13
GazL
Senior Member
 
Registered: May 2008
Posts: 3,380

Rep: Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912
Quote:
Originally Posted by geek745 View Post

GazL:

I did not write the remainder of rc.M - the default behavior was to source all subsequent rc scripts as they were - I see now that this may be the safest procedure...
I didn't say you did. The point I was making is that the stock slackware rc.M is inconsistent, sometimes sourcing stuff, other times calling them with their own shell process. I was hoping that my comment might have prompted one of the devs to consider the issue and if it turned out that they agreed then perhaps we'd see a more resilient/consistent approach in a future release.
 
Old 02-06-2009, 06:19 AM   #14
Didier Spaier
Senior Member
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slackware{,64}-{14.1,current} on a Lenovo Thinkpad T61 6457-4XG
Posts: 4,180

Rep: Reputation: 1018Reputation: 1018Reputation: 1018Reputation: 1018Reputation: 1018Reputation: 1018Reputation: 1018Reputation: 1018
Quote:
Originally Posted by GazL View Post
I was hoping that my comment might have prompted one of the devs to consider the issue and if it turned out that they agreed then perhaps we'd see a more resilient/consistent approach in a future release.
Feel free to append your proposal for enhanced startup scripts to your next post.

Last edited by Didier Spaier; 02-06-2009 at 06:39 AM.
 
Old 02-06-2009, 06:50 AM   #15
GazL
Senior Member
 
Registered: May 2008
Posts: 3,380

Rep: Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912Reputation: 912
Quote:
Originally Posted by Didier Spaier View Post
Just append your proposal for updated startup scripts to your next post.
In this case, the change is fairly self evident.
Code:
sed -e 's:\. /etc/rc.d/rc.:/bin/sh /etc/rc.d/rc.:g' /etc/rc.d/rc.M
I haven't tested it, but that's the gist of it.

Last edited by GazL; 02-10-2009 at 06:51 AM. Reason: removed dead link
 
  


Reply

Tags
apache, bash, mysql, rc, scripts, server, shell, startup


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Break scripts as a learning tool? GarKing Linux - Newbie 1 06-28-2008 05:46 PM
A lot of agetty, httpd and mysqld processes ilhbutshm Slackware 3 09-04-2006 12:49 PM
disabling mysqld and httpd webinsek Linux - Newbie 3 03-25-2006 12:13 PM
mysqld on startup... dark poet Linux - Newbie 8 10-05-2003 12:16 AM
mysqld fails on startup wiseraptor Linux - Newbie 0 02-07-2003 03:42 PM


All times are GMT -5. The time now is 10:08 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration