You are not logged in.

#1 2006-08-25 16:33:54

mr.MikyMaus
Member
From: disabled
Registered: 2006-03-31
Posts: 285

assigning daemons to different runlevels (arch init process)

Hi folks,

I'm sorry in advance for such a dumb question, but Arch's init process was a big "didn't-have-to-care-about-and-so-didn't" thing for me, up until now.

I do a little web developement and so I installed Apache, php_mod and MySQL on my laptop to test some php scripted pages. I don't need these services for all the time however, so I decided to put them into different runlevel, as I did while I was using Debian (Sys-V init).

Here I got stuck. In Sys-V init it's as easy as adding some softlinks to /etc/init.d/rc.x (or something similar) but as Arch uses somehow manufactured BSD-Style init, which is completely unknown to me, I have really no idea what to do. I don't even know where to start looking.

Read some pages at Arch Wiki, but none had enough information. Same for forums (looking for words like 'runlevel', 'init process' etc..).

So could someone of you give me a point, or a good link on some how-to? I am happily willing to learn, but I need some learnbook and I'm dumb enough to not to find any, yet..:)

I also heard about some different init styles once (one called 'runit' I think), but that would be probably big change, making Arch a not Arch, wouldn't it?:)

-M.


What happened to Arch's KISS? systemd sure is stupid but I must have missed the simple part ...

... and who is general Failure and why is he reading my harddisk?

Offline

#2 2006-08-25 17:23:48

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: assigning daemons to different runlevels (arch init process)

I don't think it's possible. The usual way to start daemons at boot up is to put them in the DAEMONS array of rc.conf and that starts the daemons in initlevel 3.
If you don't use them all the time, you can start them manually like so:

# /etc/rc.d/httpd start

and stop them with:

# /etc/rc.d/httpd stop

If you have to start several of them (apache and mysql), you could write a script to simplify things. Maybe someone will have a better suggestion.

Offline

#3 2006-08-25 17:29:42

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: assigning daemons to different runlevels (arch init process)

That's not the way arch is intended to be used, really.  However, it's actually real trivial to do something like this, if you don't want to manually start things by hand (which is really all you're doing when switching runlevels):

# /etc/level4init
/etc/rc.d/httpd start
/etc/rc.d/mysqld start
# /etc/inittab
... blah blah...
l4:4:/etc/level4init

Offline

#4 2006-08-25 18:06:13

ralvez
Member
From: Canada
Registered: 2005-12-06
Posts: 1,718
Website

Re: assigning daemons to different runlevels (arch init process)

I have two machines, my development machine and another where I somtetimes do development.
In the second machine I do not want to run apache and mysql all the time, since it is not needed, so I created this simple script that I run whenever I use that machine:

UID=id
clear

if [ $UID != 0 ]; then
echo "You must be root to run this script"
exit;
else
echo "+=======================================+"
echo "| Starting LAMP Development Environment |"
echo "+=======================================+"
echo "Apache Web Sever"
/etc/rc.d/httpd start
echo " mySQL Database"
/etc/rc.d/mysqld start
echo
echo "+=======================================+"
fi

Hope this helps.

R

Offline

#5 2006-08-25 20:11:28

mr.MikyMaus
Member
From: disabled
Registered: 2006-03-31
Posts: 285

Re: assigning daemons to different runlevels (arch init process)

Than you guys for all suggestions, all where well-pointed.

to ralvez: nice tip with that "root-only" thing, nothing like that would probably cme up in my mind, if I was writing such script wink

I was thinking about some "just-run-a-script" solution, but using runlevels was, well, more UNIX smile I mean, that's what runlevels are ment for, isn't it?

So, thanks to phrakture, I did 'man inittab' and came up with this:

[miky@ghoulie ~]$ cat /etc/inittab 
#
# /etc/inittab
#

#  Runlevels:
#    0    Halt
#    1(S)    Single-user
#    2    Not used
#    3    Multi-user
#    4    Not used
#    5    X11
#    6    Reboot

id:5:initdefault:

rc::sysinit:/etc/rc.sysinit
rs:S1:wait:/etc/rc.single
rm:2345:wait:/etc/rc.multi
rh:06:wait:/etc/rc.shutdown
su:S:wait:/sbin/sulogin -p

c1:2345:respawn:/sbin/agetty 38400 vc/1 linux
c2:2345:respawn:/sbin/agetty 38400 vc/2 linux
c3:2345:respawn:/sbin/agetty 38400 vc/3 linux
c4:2345:respawn:/sbin/agetty 38400 vc/4 linux
c5:2345:respawn:/sbin/agetty 38400 vc/5 linux
c6:2345:respawn:/sbin/agetty 38400 vc/6 linux

ca::ctrlaltdel:/sbin/shutdown -t3 -r now

x:45:respawn:/usr/bin/slim
l4:4:once:/etc/rc.d/runlevel4.sh 

# End of file
[miky@ghoulie ~]$ cat /etc/rc.d/runlevel4.sh
#!/bin/bash

start()
{
    /etc/rc.d/httpd start
    /etc/rc.d/mysqld start
}

interrupt()
{
    /etc/rc.d/mysql stop
    /etc/rc.d/httpd stop

    exit 0
}

start
trap interrupt INT
read

The only thing I don't like on this solution is how to keep the runlevel4 script running, or better sleeping. I tried an infinte loop using well-known while /bin/true; do sleep 1; done, but that was changing proceses pid every second.

Does anyone know a better (or better, the best smile ) solution for this?

-M.


What happened to Arch's KISS? systemd sure is stupid but I must have missed the simple part ...

... and who is general Failure and why is he reading my harddisk?

Offline

Board footer

Powered by FluxBB