Subject: Re: JAVA application as Daemon
To: None <yoskim@nmsu.edu>
From: David S. <davids@idiom.com>
List: netbsd-users
Date: 07/05/2003 16:45:15
>
> I am trying to get my daemon to work still. With the great help of people here, I
> was able to manage it to run. However, whenever I tried to stop my daemon
> using the command
>
> # my_daemon stop
>
> It simply said there ws no such daemon running. I checked the status of it, and I
> got the same result. I came to know that it was because my_daemon was
> actually a script that ran another program, ie. a JAVA application. So, on the
> process table, there was no "my_daemon" running, but rather "my_JAVA" was
> running. Thus, I now need to find a way to change the name of the
> program "my_JAVA" to "my_daemon" on the process table to be able to stop the
> daemon. Or better yet, I need to find a better and conventional way to deal with
> this kind of situation. How would I go about do this?
>
> As an attempt, I had written a C program and have it run "execlp("jre", path[0],
> path[1],...);" where path[0]="my_daemon". However, it still kept the "jre" as the
> program running on the process table. So, it didnt work
>
> Do I need to play with "rc" files?
Use 'getpid' to get the process ID, and record it in
"/var/run/some_name.pid". In your 'rc' script, set
'pidfile="/var/run/some_name.pid". Then your 'rc' script
should be able to stop your program: '/etc/rc.d/some_name stop'.
See many examples in '/etc/rc.d'.
David S.
>