🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #2247

Re: Starting process as Service

#2247
From: Joi Ellis [TeamB]
Date: Fri, 06 Apr 2001 22:31
59 lines
2531 bytes
kkaal <kkaal@t-online.de> wrote:
> Joi,
> I really tried hard to find a daemon routine - no success. As I am not
> experienced on linux, I have no idea how to make my program a daemon
> process. But I have to make it.
> Any other idea???

Here's a simple system startup script I created for launching tomcat at boot
time on my development machine.

[joi@joi init.d]$ more /etc/rc.d/init.d/tomcat 

#!/bin/sh
export JAVA_HOME=/usr/local/java/jdk1.3
export TOMCAT_HOME=/usr/local/src/jakarta-tomcat-3.2.1
#su - nobody -c "$TOMCAT_HOME/bin/tomcat.sh $@"
$TOMCAT_HOME/bin/tomcat.sh $@

This runs tomcat as root. (Not a good idea, but this is my private development
machine.)  You'd want to use the 'su' variant and replace 'nobody' with the
username under which your daemon should run, assuming it isn't root.

The 'daemon' thing I mentioned before is a shell script function found
in file /etc/rc.d/init.d/functions.  It is called from many of Red Hat's
system startup scripts in /etc/rc.d/init.d. I could probably have written
my own script as (untested):

#!/bin/sh

.. /etc/rc.d/init.d/functions

export JAVA_HOME=/usr/local/java/jdk1.3
export TOMCAT_HOME=/usr/local/src/jakarta-tomcat-3.2.1

case "$1" in
  start)
    echo -n "Starting tomcat: "
    daemon $TOMCAT_HOME/bin/tomcat.sh $@
    ;;
  stop)
    echo -n "Shutting down tomcat: "
    killproc tomcat
    ;;
  restart)
    $0 stop
    $0 start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac

exit 0

-- 
Joi Ellis (TeamB) 
No direct email, please.
For best results, post on news server newsgroups.borland.com!
Newsgroup Info: http://www.borland.com/newsgroups/guide.html
Technical Details
Message-ID: <3ace43b3_1@dnews>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!fu-berlin.de!news.boerde.de!dnews!not-for-mail
References: <9adbit$sqk$06$1@news.t-online.com> <3aca39b1_2@dnews> <3acadd42_2@dnews> <3acb2f33_2@dnews> <9akmtb$gh6$05$1@news.t-online.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,aa0d76ffc55efaf3
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2001-04-06 15:46:03 PST
Message-ID: <3ace43b3_1@dnews>
From: "Joi Ellis [TeamB]" <joi@aravox.com>
Subject: Re: Starting process as Service
Newsgroups: borland.public.jbuilder.java.api
References: <9adbit$sqk$06$1@news.t-online.com> <3aca39b1_2@dnews> <3acadd42_2@dnews> <3acb2f33_2@dnews> <9akmtb$gh6$05$1@news.t-online.com>
User-Agent: tin/1.4.2-20000205 ("Possession") (UNIX) (Linux/2.2.16-3 (i686))
NNTP-Posting-Host: 209.46.41.66
Date: 6 Apr 2001 15:31:15 -0700
X-Trace: dnews 986596275 209.46.41.66 (6 Apr 2001 15:31:15 -0700)
Lines: 59
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!fu-berlin.de!news.boerde.de!dnews!not-for-mail