[ic] Interchange as a System service.
jfoster at augustmail.com
Wed Mar 16 10:10:12 EST 2005
On Monday 14 March 2005 06:17 pm, Daniel Davenport wrote:
> >>> andreb at techess.com 03/10/05 08:48PM >>>
> > Hi all.. how do i setup interchange as a service to start up on the
> > different run levels..
> > Andre
> (NOTE: this message describes how RH/Fedora does services. YMMV. If
> you use another flavor of Linux, i guarantee nothing about how well this
> stuff works.)
> The only thing "special" about services, as opposed to other daemons,
> is that a service has a script in /etc/init.d (and links in
> /etc/rc.d/rc[0-6].d) that can tell the daemon to start, stop, or
> whatever. You need a script like the ones in /etc/rc.d/init.d, but
> which instead of starting sshd or apache or whatever, starts
> interchange. It's not too hard to write....it can just be a shell
> script that takes a command as the first parameter/argument/whatever.
> Personally, since i'm not a whiz with shell scripts, i'll often just
> make a copy of one of the existing scripts and change the commands
> around to suit the service i need started. Replace
> '/usr/sbin/someotherd' with '/usr/local/interchange/bin/interchange',
> etc. :) Look at the various scripts in init.d; one is usually better
> than others for making these kinds of changes.
> (note: since IC usually runs as interch(ange)?, you might do better to
> just strip out the start and stop commands and put in what you usually
> put in to start IC. su -c and all.)
> The commands can be just about anything....apache, for example,
> responds to a "configtest" command--which runs just long enough to
> check/parse the config files, and doesn't disturb the already-running
> server. Helpful. :) If you want your service's script to be useful,
> you'll need to at least respond to 'start' and 'stop' commands.
> 'restart' would be good too.
> init.d scripts also have a couple of comment lines near the top of the
> file that describe the service and specify what runlevels the service
> should start in by default, and in what order it should start (relative
> to other programs in the same runlevel). If you look at other scripts
> in init.d, you'll see a line like
> # chkconfig: 2345 60 40
> That's the important one--it specifies the default runlevels, start
> order, and stop order for the service. The first number is really a
> string of digits, one for each default runlevel. '2345' means the
> service will start in all the standard runlevels, unless you tell it to
> do otherwise. (0, 1, and 6 are special. Don't set up a daemon to run
> in any of those runlevels.) The last two numbers are the start order
> and stop order respectively, should each be two digits, and can be
> anything from 00 to 99. Services with 00 as their start order will be
> started first, and 99 means it wil be started last. In the case of IC,
> make sure it starts after all of the services it depends on (httpd,
> postgres or mysqld, network, etc), and stops before any of them....or
> there will be trouble. Personally, i prefer that the numbers add up to
> 99 or 100....just because that helps make sure that what starts last
> stops first, and vice versa.
> Your safest bet is to use a line like
> #chkconfig: 2345 99 00
> This will make IC one of the last services to start, and one of the
> first to stop. Until you're comfortable with manipulating services,
> paranoia is not a bad thing.
> Another line you'll find useful is
> # description: Starts and stops the Interchange server.
> Whatever you put after description: will be shown in programs like
> system-config-services (or redhat-config-services, for the rh[8-9]
> folks) when you click on the service name. I'm not sure whether this
> line is really required (although i've never had a problem, `man
> chkconfig` suggests it is), but it can't hurt to include it.
> when your script is done, cp/mv it to /etc/rc.d/init.d/interchange.
> chmod it a-rwx,u=rx; and chown it to root.root. Then say "chkconfig
> --add interchange". That'll put the symlinks in the right places so
> that IC starts at the right time.
> Once your script is in init.d and properly chmodded, you can say
> "service interchange start". Guess what that does.
Seems like I used to do something like this years ago with Minivend. I fact I
still do. A good point to remember is "Never leave any white space at the
front of a line in an 'init.d' script". That means no indents or other neat
More information about the interchange-users