starting a java application as a service

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



I don't recall seeing a response to this request, and I'm nothing of an expert in Java, so here's a some-what educated guess:

Where you invoke "/usr/bin/java -cp /usr/local/lib/java/jes.jar Jes $JESARGS"
put "daemon " in front of that line.
daemon /usr/bin/java -cp /usr/local/lib/java/jes.jar Jes $JESARGS
and give that a whirl.
(daemon is the function brought in by the script processor for startup 
services that backgrounds/detaches  the call to the service itself

Brian Brunner
brian.t.brunner@xxxxxxxxxxxxxxx
(610)796-5838

>>> ByrneJB@xxxxxxxxxxxxx 10/24/05 05:19PM >>>
I have a single requirement to launch a java application on startup 
as a service.  The application is shipped in a file called jes.jar. 
 It requires three arguments: a dotted quad IP address,  an initial 
service port, and a translated service port.

I can get the application running as a console command.  Can 
someone point me to a site that documents how to script a sys V 
init.d style script so that I can run this as a daemon process?  I 
tried copying a script in the age old fashion but I seem to be 
missing something(s).

Lastly, I vaguely recall that there is a way to capture the pid of 
a program started in the shell but I cannot find any reference to 
it.  I seem to recall that the construct $! or $$ contained the 
value of the last program run.  Can anyone here confirm this and/or 
provide an example.

I am a digest subscriber so direct responses are appreciated (reply 
to all).

Sample script

#!/bin/sh
#
# jes:          Java Encryption Server for Javelin NSTV 
connections.
#
# chkconfig:    - 26 89
# description:	Java Encryption Service to support SSL 
# 				connections for the  Javelin HP3000 NS/VT 
#				emulator java applette.
#

#       Check if config file readable (and therefore exists).
[ -r /etc/sysconfig/jes ] || exit 0

#       Read and execute the config file.
.. /etc/sysconfig/jes

#       Check if variable has length zero and exit if true.
[ -z "$JESARGS" ] && exit 0

start()
{
        echo -n $"Starting jes as daemon: "
        /usr/bin/java -cp /usr/local/lib/java/jes.jar Jes $JESARGS
        touch /var/lock/subsys/jes
        echo
}

stop()
{
        echo -n $"Shutting down jes (Java Encryption Service): "
        /usr/bin/jes -K
        killproc jes

        rm -f  /var/lock/subsys/jes
        echo
}

[ -f /usr/bin/jes ] || exit 0

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        ;;
  condrestart)
        [ -e /var/lock/subsys/jes ] && (stop; start)
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|condrestart}"
        exit 1
esac

exit 0

sample configuration file:

# Options to Jes server for secure javelin connections
# VTNAME IP address of NSVT host (usually an HP3000)
VTNAME="192.168.0.12"

# VTPORT The service port that the NSVT service is listening 
#		on (Usually 1570)
VTPORT="1570"

# JESPORT 	The service port that JES listens to on this host for VT
#			Javelin	connections.  This can be any port but it is 
#			required that:
#				a.	This port must be allowed through any exterior 
#					firewalls.
#		         b.	The client must have the same port configured 
#					in default.j92
#					(or encrypt.j92 if that is what you are using).
JESPORT="1570"

# These are concatenated here for use in the init.d script.
JESARGS="$VTNAME $VTPORT $JESPORT"

--   
     *** e-mail is not a secure channel ***
mailto:byrnejb.<token>@harte-lyne.ca
James B. Byrne                Harte & Lyne Limited
vox: +1 905 561 1241          9 Brockley Drive
fax: +1 905 561 0757          Hamilton, Ontario
<token> = hal                 Canada L8E 3C3

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx 
http://lists.centos.org/mailman/listinfo/centos

*******************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept
for the presence of computer viruses.

www.hubbell.com - Hubbell Incorporated

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux