You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Daniel Perry <d....@netcase.co.uk> on 2004/03/01 12:46:59 UTC

load at bootup

How would I go about starting james on bootup (Linux)?
I'm using Fedora core 1 if that's any help!

Thanks,
Daniel Perry.

RE: load at bootup

Posted by "Noel J. Bergman" <no...@devtech.com>.
> If I use "su" in the script, then I should provide a password in the
script?
> But it's not secure. Are there other ways around?

Since SysVInit scripts run as root, no password is necessary.

I see that you are using Microsoft Outlook Express for e-mail.  You may want
to get some books on linux if you are new to it.

        --- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: load at bootup

Posted by Pavel Degtiarev <pa...@uxg.com>.
If I use "su" in the script, then I should provide a password in the script?
But it's not secure. Are there other ways around?

Thanks,
Pavel.

----- Original Message ----- 
From: "Noel J. Bergman" <no...@devtech.com>
To: "James Users List" <se...@james.apache.org>
Sent: Monday, March 01, 2004 4:35 PM
Subject: RE: load at bootup


> > Is it possible to start James service using the startup script on Linux
> > under some user, created specifically for James mail server?
>
> On *nix, root is necessary for privileged ports.  There are ways around
that
> using ip forwarding.  If you do so, you can use su in the script to start
> James as a non-privileged user.
>
> For SE Linux, one might use roles.
>
>         --- Noel
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: load at bootup

Posted by "Noel J. Bergman" <no...@devtech.com>.
> Is it possible to start James service using the startup script on Linux
> under some user, created specifically for James mail server?

On *nix, root is necessary for privileged ports.  There are ways around that
using ip forwarding.  If you do so, you can use su in the script to start
James as a non-privileged user.

For SE Linux, one might use roles.

        --- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: load at bootup

Posted by Pavel Degtiarev <pa...@uxg.com>.
Is it possible to start James service using the startup script on Linux
under some user, created specifically for James mail server?

Pavel.

----- Original Message ----- 
From: "Noel J. Bergman" <no...@devtech.com>
To: "James Users List" <se...@james.apache.org>
Sent: Monday, March 01, 2004 11:28 AM
Subject: RE: load at bootup


> Serge Knystautas wrote:
> > Daniel Perry wrote:
> > > How would I go about starting james on bootup (Linux)?
> > > I'm using Fedora core 1 if that's any help!
>
> > I create a symlink to make James a service, then set that service to
> > start at boot time...
>
> > ln -s /usr/local/james/bin/phoenix.sh /etc/init.d/james
>
> > Then put a link to that in rc3.d or however you want to make the service
> > start at boot time.
>
> I use the attached.  Place it, or a symlink, in /etc/rc.d/init.d.  Then
run
>
>  $ chkconfig --add james
>
> to have it installed.  See "man chkconfig" for other options.  The easy
way
> to access the scripts is the service command, e.g.,
>
>  $ service james [start | stop | restart]
>
> phoenix.sh has some options not yet supported in this script, but doesn't
> integrate with the runlevel level scheme.
>
> --- Noel
>


----------------------------------------------------------------------------
----


> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: load at bootup

Posted by Daniel Perry <d....@netcase.co.uk>.
Yep,
But that is what phoenix.sh does after stopping the process (but is failing
to do).

As i said: "service james stop" does delete the file, but "shutdown -r now"
doesnt.

For now it is working with the modified phoenix.sh start section.
I will continue messing with these scripts when i have some spare time, to
try and determine what is going on.  My guess is that "shutdown -r now" is
inpatient, and is killing the script somewhere.

Daniel.


-----Original Message-----
From: Ray Tran [mailto:ray@westhawk.co.uk]
Sent: 05 March 2004 10:17
To: James Users List
Subject: Re: load at bootup


The normal way of dealing with this is to delete the pid file in the
stop) section after doing whatever
stops the service. e.g. assuming the pidfile is /var/run/james.pid :
        stop)
            echo -n "Shutting down James Mail Server "
            export JAVA_HOME=/usr/local/java
            /opt/james/bin/phoenix.sh stop
            rm /var/run/james.pid
           echo
           ;;

Daniel Perry wrote:

>This was not fun to solve.  For some reason, the phoenix.pid file is
getting
>left behind. So when it reboots is doesnt startup - phoenix.sh just says
>it's started! i was being fooled by the shell script :(
>
>Anyway, i found a couple of ways round this - simply change
>/etc/init.d/james so that the start part deletes the pid file!
>but this is sloppy as you could start it twice using service start.
>
>So, the better way is to alter phoenix.sh so it doesnt just look for the
>file - it verifies that the pid file is a process! This is my first attempt
>at shell coding, so it's a bit unprofessional looking, but it works!
>
>Simply replace the origional code:
>
>        if [ -f $PHOENIX_PID ]
>        then
>            echo "Already Running!!"
>            exit 1
>        fi
>
>With:
>
>if [ -f $PHOENIX_PID ]
>then
>        phpid=`cat $PHOENIX_PID 2>/dev/null`
>        piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
>        if [ "$piddata" != "" ]
>        then
>                echo "Already Running!!"
>                exit 1
>        fi
>fi
>
>Not sure wether the phoenix team would be interested in doing somthing
>similar so as to avoid this kind of problem!
>
>Daniel.
>
>-----Original Message-----
>From: Daniel Perry [mailto:d.perry@netcase.co.uk]
>Sent: 03 March 2004 17:55
>To: James Users List
>Subject: RE: load at bootup
>
>
>Ok, i went down this service approach (tried both approaches - symlink to
>phoenix, and the script noel sent).
>
>It works a treat with "service james start", "service james stop".
>
>BUT, if i reboot, it doesnt start up properly. (this only if it was running
>at reboot).
>
>Phoenix does start because if you try to start james again it says it's
>already running! However, it isnt listening on any ports. stop it and start
>it and it's fine.
>
>Note, it also doesnt generate any log files.
>
>To clarrify:
>
>if james is running fine, and i do:
># shutdown -r now"
>when the server reboots, james is running, but doesnt listen!
>
>if james is running fine, and i do:
># service james stop
># shutdown -r now
>when the server reboots, james is running, and is listening!
>
>Any ideas? cos i'm stumped!
>
>Thanks,
>
>Daniel.
>
>
>
>-----Original Message-----
>From: Noel J. Bergman [mailto:noel@devtech.com]
>Sent: 01 March 2004 16:29
>To: James Users List
>Subject: RE: load at bootup
>
>
>Serge Knystautas wrote:
>
>
>>Daniel Perry wrote:
>>
>>
>>>How would I go about starting james on bootup (Linux)?
>>>I'm using Fedora core 1 if that's any help!
>>>
>>>
>
>
>
>>I create a symlink to make James a service, then set that service to
>>start at boot time...
>>
>>
>
>
>
>>ln -s /usr/local/james/bin/phoenix.sh /etc/init.d/james
>>
>>
>
>
>
>>Then put a link to that in rc3.d or however you want to make the service
>>start at boot time.
>>
>>
>
>I use the attached.  Place it, or a symlink, in /etc/rc.d/init.d.  Then run
>
> $ chkconfig --add james
>
>to have it installed.  See "man chkconfig" for other options.  The easy way
>to access the scripts is the service command, e.g.,
>
> $ service james [start | stop | restart]
>
>phoenix.sh has some options not yet supported in this script, but doesn't
>integrate with the runlevel level scheme.
>
>	--- Noel
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>For additional commands, e-mail: server-user-help@james.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>For additional commands, e-mail: server-user-help@james.apache.org
>
>
>
Regards,

--
Ray Tran



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: load at bootup

Posted by Ray Tran <ra...@westhawk.co.uk>.
The normal way of dealing with this is to delete the pid file in the 
stop) section after doing whatever
stops the service. e.g. assuming the pidfile is /var/run/james.pid :
        stop)
            echo -n "Shutting down James Mail Server "
            export JAVA_HOME=/usr/local/java
            /opt/james/bin/phoenix.sh stop
            rm /var/run/james.pid
           echo
           ;;

Daniel Perry wrote:

>This was not fun to solve.  For some reason, the phoenix.pid file is getting
>left behind. So when it reboots is doesnt startup - phoenix.sh just says
>it's started! i was being fooled by the shell script :(
>
>Anyway, i found a couple of ways round this - simply change
>/etc/init.d/james so that the start part deletes the pid file!
>but this is sloppy as you could start it twice using service start.
>
>So, the better way is to alter phoenix.sh so it doesnt just look for the
>file - it verifies that the pid file is a process! This is my first attempt
>at shell coding, so it's a bit unprofessional looking, but it works!
>
>Simply replace the origional code:
>
>        if [ -f $PHOENIX_PID ]
>        then
>            echo "Already Running!!"
>            exit 1
>        fi
>
>With:
>
>if [ -f $PHOENIX_PID ]
>then
>        phpid=`cat $PHOENIX_PID 2>/dev/null`
>        piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
>        if [ "$piddata" != "" ]
>        then
>                echo "Already Running!!"
>                exit 1
>        fi
>fi
>
>Not sure wether the phoenix team would be interested in doing somthing
>similar so as to avoid this kind of problem!
>
>Daniel.
>
>-----Original Message-----
>From: Daniel Perry [mailto:d.perry@netcase.co.uk]
>Sent: 03 March 2004 17:55
>To: James Users List
>Subject: RE: load at bootup
>
>
>Ok, i went down this service approach (tried both approaches - symlink to
>phoenix, and the script noel sent).
>
>It works a treat with "service james start", "service james stop".
>
>BUT, if i reboot, it doesnt start up properly. (this only if it was running
>at reboot).
>
>Phoenix does start because if you try to start james again it says it's
>already running! However, it isnt listening on any ports. stop it and start
>it and it's fine.
>
>Note, it also doesnt generate any log files.
>
>To clarrify:
>
>if james is running fine, and i do:
># shutdown -r now"
>when the server reboots, james is running, but doesnt listen!
>
>if james is running fine, and i do:
># service james stop
># shutdown -r now
>when the server reboots, james is running, and is listening!
>
>Any ideas? cos i'm stumped!
>
>Thanks,
>
>Daniel.
>
>
>
>-----Original Message-----
>From: Noel J. Bergman [mailto:noel@devtech.com]
>Sent: 01 March 2004 16:29
>To: James Users List
>Subject: RE: load at bootup
>
>
>Serge Knystautas wrote:
>  
>
>>Daniel Perry wrote:
>>    
>>
>>>How would I go about starting james on bootup (Linux)?
>>>I'm using Fedora core 1 if that's any help!
>>>      
>>>
>
>  
>
>>I create a symlink to make James a service, then set that service to
>>start at boot time...
>>    
>>
>
>  
>
>>ln -s /usr/local/james/bin/phoenix.sh /etc/init.d/james
>>    
>>
>
>  
>
>>Then put a link to that in rc3.d or however you want to make the service
>>start at boot time.
>>    
>>
>
>I use the attached.  Place it, or a symlink, in /etc/rc.d/init.d.  Then run
>
> $ chkconfig --add james
>
>to have it installed.  See "man chkconfig" for other options.  The easy way
>to access the scripts is the service command, e.g.,
>
> $ service james [start | stop | restart]
>
>phoenix.sh has some options not yet supported in this script, but doesn't
>integrate with the runlevel level scheme.
>
>	--- Noel
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>For additional commands, e-mail: server-user-help@james.apache.org
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
>For additional commands, e-mail: server-user-help@james.apache.org
>
>  
>
Regards,

-- 
Ray Tran



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Checking PHOENIX_PID for validity

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 04 March 2004 18:53, Daniel Perry wrote:
> >> (should it not be phoenix\.home really)
>
> Why? (i'm new to this!) is it just escaping? or somthing else?

phoenix.home  ->  This is regular expression and the dot means "any 
character".

phoenix\.home  ->  Means the dot character.


So in the first the following will resolve true;

phoenix.home
phoenix/home
phoenix+home
phoenixAhome


Cheers
Niclas
-- 
+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Checking PHOENIX_PID for validity

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 04 March 2004 20:33, Daniel Perry wrote:
> Is there any way of finding out what is happening on shutdown (this is a
> remote server, so i dont get any screen output!)

It should be listed in /var/log/boot.log
Also, the phoenix script outputs to $PHOENIX_TMPDIR/phoenix.console, but I am 
not sure how that relates to James.


> I'm not sure what is happeneing, but i figure it must be calling the stop
> script, but for some reason it either isnt running properly, or it's
> getting killed before completing (does linux do this? is there a timelimit
> for stop calls?)

I know that there is none during startup, and assume shutdown is the same. 
Looking at the phoenix script, it is a two phased shutdown, send a  "kill 
SIGTERM" first, wait a while and then "kill SIGKILL", and the latter will 
just remove the process from memory without necassry letting it shutdown 
completely. In any event, the .pid file is removed by the script.
The phoenix script defaults to 5 second delay, prior to the SIGKILL, but can 
be set with the $PHOENIX_KILLDELAY variable.

Niclas

> Daniel.
>
> -----Original Message-----
> From: Niclas Hedhman [mailto:niclas@hedhman.org]
> Sent: 04 March 2004 12:16
> To: Avalon Developers List; Daniel Perry; James Users List
> Cc: Avalon Developers List
> Subject: Re: Checking PHOENIX_PID for validity
>
> On Thursday 04 March 2004 18:53, Daniel Perry wrote:
> > >>Sounds as if you down have it registered to be stopped during shutdown.
> >
> > Ok, that was my guess...
> > But again, being new to this, how do you do that? I thought having it
> > registered as a service, it would be done for me...
> >
> > [root@p4-7138 root]# chkconfig --list | grep james
> > james           0:off   1:off   2:off   3:on    4:on    5:on    6:off
>
> I am not sure which OS you are running, but the standard mechanism for
> startup
> and shutdown under System V is that you have a "initi.d" directory
> containing
> the script itself, which understand "start" and "stop" argument.
> Then there is a "rcN.d" containing the symbolic link to the
> "init.d/phoenix-server.sh", and is "prepended" with an "Sxx" or a "Kxx".
>
> N stands for the RunLevel, and those are slightly different on each OS. On
> my
> Linux 3 is for Multiuser text mode, and 5 is for MultiUser X Desktop and 6
> for shutdown.
>
> xx is a number to control the order in which things are started or
> shutdown.
>
> So you look through the existing list and figure out how soon or how late
> in the sequence it must start or stop.
>
> So you do something like;
>
> ln -s /etc/init.d/phoenix-server.sh /etc/rc3.d/S95phoenix.sh
> ln -s /etc/init.d/phoenix-server.sh /etc/rc5.d/S95phoenix.sh
> ln -s /etc/init.d/phoenix-server.sh /etc/rc6.d/K10phoenix.sh
>
> I hope this helps.
>
> Niclas
> --
> +---------//-------------------+
>
> |   http://www.bali.ac         |
> |  http://niclas.hedhman.org   |
>
> +------//----------------------+

-- 
+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: Checking PHOENIX_PID for validity

Posted by Daniel Perry <d....@netcase.co.uk>.
I'm running fedora 1.

I have exactly as you say - a script i put in init.d (which does start, stop
and restart)

I used chkconfig to install and set runlevels for the james script. It
appears to have done it's job, as there are Sxx and Kxx symlinks in the
rcN.d directories.

The script works fine used through the "service" command.  "service james
stop" which uses the etc/init.d/james script works fine!

Is there any way of finding out what is happening on shutdown (this is a
remote server, so i dont get any screen output!)

I'm not sure what is happeneing, but i figure it must be calling the stop
script, but for some reason it either isnt running properly, or it's getting
killed before completing (does linux do this? is there a timelimit for stop
calls?)

Daniel.

-----Original Message-----
From: Niclas Hedhman [mailto:niclas@hedhman.org]
Sent: 04 March 2004 12:16
To: Avalon Developers List; Daniel Perry; James Users List
Cc: Avalon Developers List
Subject: Re: Checking PHOENIX_PID for validity


On Thursday 04 March 2004 18:53, Daniel Perry wrote:
> >>Sounds as if you down have it registered to be stopped during shutdown.
>
> Ok, that was my guess...
> But again, being new to this, how do you do that? I thought having it
> registered as a service, it would be done for me...
>
> [root@p4-7138 root]# chkconfig --list | grep james
> james           0:off   1:off   2:off   3:on    4:on    5:on    6:off

I am not sure which OS you are running, but the standard mechanism for
startup
and shutdown under System V is that you have a "initi.d" directory
containing
the script itself, which understand "start" and "stop" argument.
Then there is a "rcN.d" containing the symbolic link to the
"init.d/phoenix-server.sh", and is "prepended" with an "Sxx" or a "Kxx".

N stands for the RunLevel, and those are slightly different on each OS. On
my
Linux 3 is for Multiuser text mode, and 5 is for MultiUser X Desktop and 6
for shutdown.

xx is a number to control the order in which things are started or shutdown.

So you look through the existing list and figure out how soon or how late in
the sequence it must start or stop.

So you do something like;

ln -s /etc/init.d/phoenix-server.sh /etc/rc3.d/S95phoenix.sh
ln -s /etc/init.d/phoenix-server.sh /etc/rc5.d/S95phoenix.sh
ln -s /etc/init.d/phoenix-server.sh /etc/rc6.d/K10phoenix.sh

I hope this helps.

Niclas
--
+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Checking PHOENIX_PID for validity

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 04 March 2004 18:53, Daniel Perry wrote:
> >>Sounds as if you down have it registered to be stopped during shutdown.
>
> Ok, that was my guess...
> But again, being new to this, how do you do that? I thought having it
> registered as a service, it would be done for me...
>
> [root@p4-7138 root]# chkconfig --list | grep james
> james           0:off   1:off   2:off   3:on    4:on    5:on    6:off

I am not sure which OS you are running, but the standard mechanism for startup 
and shutdown under System V is that you have a "initi.d" directory containing 
the script itself, which understand "start" and "stop" argument.
Then there is a "rcN.d" containing the symbolic link to the 
"init.d/phoenix-server.sh", and is "prepended" with an "Sxx" or a "Kxx".

N stands for the RunLevel, and those are slightly different on each OS. On my 
Linux 3 is for Multiuser text mode, and 5 is for MultiUser X Desktop and 6 
for shutdown.

xx is a number to control the order in which things are started or shutdown.

So you look through the existing list and figure out how soon or how late in 
the sequence it must start or stop.

So you do something like;

ln -s /etc/init.d/phoenix-server.sh /etc/rc3.d/S95phoenix.sh
ln -s /etc/init.d/phoenix-server.sh /etc/rc5.d/S95phoenix.sh
ln -s /etc/init.d/phoenix-server.sh /etc/rc6.d/K10phoenix.sh

I hope this helps.

Niclas
-- 
+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Checking PHOENIX_PID for validity

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 04 March 2004 18:53, Daniel Perry wrote:
> >>Sounds as if you down have it registered to be stopped during shutdown.
>
> Ok, that was my guess...
> But again, being new to this, how do you do that? I thought having it
> registered as a service, it would be done for me...
>
> [root@p4-7138 root]# chkconfig --list | grep james
> james           0:off   1:off   2:off   3:on    4:on    5:on    6:off

I am not sure which OS you are running, but the standard mechanism for startup 
and shutdown under System V is that you have a "initi.d" directory containing 
the script itself, which understand "start" and "stop" argument.
Then there is a "rcN.d" containing the symbolic link to the 
"init.d/phoenix-server.sh", and is "prepended" with an "Sxx" or a "Kxx".

N stands for the RunLevel, and those are slightly different on each OS. On my 
Linux 3 is for Multiuser text mode, and 5 is for MultiUser X Desktop and 6 
for shutdown.

xx is a number to control the order in which things are started or shutdown.

So you look through the existing list and figure out how soon or how late in 
the sequence it must start or stop.

So you do something like;

ln -s /etc/init.d/phoenix-server.sh /etc/rc3.d/S95phoenix.sh
ln -s /etc/init.d/phoenix-server.sh /etc/rc5.d/S95phoenix.sh
ln -s /etc/init.d/phoenix-server.sh /etc/rc6.d/K10phoenix.sh

I hope this helps.

Niclas
-- 
+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Checking PHOENIX_PID for validity

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 04 March 2004 18:53, Daniel Perry wrote:
> >> (should it not be phoenix\.home really)
>
> Why? (i'm new to this!) is it just escaping? or somthing else?

phoenix.home  ->  This is regular expression and the dot means "any 
character".

phoenix\.home  ->  Means the dot character.


So in the first the following will resolve true;

phoenix.home
phoenix/home
phoenix+home
phoenixAhome


Cheers
Niclas
-- 
+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: Checking PHOENIX_PID for validity

Posted by Daniel Perry <d....@netcase.co.uk>.
I agree.  It's making assumptions like this that caused the problem in the
first place (origional assumption being phoenix.pid exists means it's
running....)

I think my assumption of it running if there's a process under the recorded
id (small chance of it being somthing else) and having "phoenix.home" in it
(very very small chance of it being somthing else).

This is the fist bit of shell script i've ever written, and i'm amazed it
works...
>> (should it not be phoenix\.home really)

Why? (i'm new to this!) is it just escaping? or somthing else?


>>Sounds as if you down have it registered to be stopped during shutdown.

Ok, that was my guess...
But again, being new to this, how do you do that? I thought having it
registered as a service, it would be done for me...

[root@p4-7138 root]# chkconfig --list | grep james
james           0:off   1:off   2:off   3:on    4:on    5:on    6:off

I thought that meant it would be be turned off for halt (0) and reboot (6).

Correct me if i'm wrong :)

Daniel.

-----Original Message-----
From: Christian Andersson [mailto:ca@ofs.no]
Sent: 04 March 2004 06:35
To: James Users List
Subject: Re: Checking PHOENIX_PID for validity


I only see one problem with the one that is in CVS compared to the one
that was offered. The CVS one does not take in account that linux reuses
the process numbers, and therefore there can be some other process that
use the same pid, the one offered tries to take this into account with
the usage of grep phoenix.home  (should it not be phoenix\.home really)

Especially if the main problem is after a unclean shutdown of the james
server and then an reboot of the machine this would be the case.

I have some time ago downloaded a shell script some time ago that was
designed to be used for the init.d (with start,stop,restart,status, etc)
This script has the same problem, and I was baffled before I discovered
it why my servers would not start at a reboot. I ended up having to code
in not just checking that the process was living,but that it was a java
process that had some parameters that identified it as my server.

/Christian

Niclas Hedhman wrote:
> On Thursday 04 March 2004 08:46, Noel J. Bergman wrote:
>
>>>        if [ -f $PHOENIX_PID ]
>>>        then
>>>            phpid=`cat $PHOENIX_PID 2>/dev/null`
>>>            piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
>>>            if [ "$piddata" != "" ]
>>>            then
>>>                    echo "Already Running!!"
>>>                    exit 1
>>>            fi
>>>        fi
>>>
>>>Not sure wether the phoenix team would be interested in doing somthing
>>>similar so as to avoid this kind of problem!
>>
>>I'll cc the Avalon folks so that they can consider it.
>
>
>
> This is already present in Phoenix, at least what is in the CVS.
>
>   start)
>         echo "Starting Phoenix: "
>
>         if [ -f $PHOENIX_PID ]
>         then
>            if ps -p `cat $PHOENIX_PID ` >/dev/null 2>/dev/null
>            then
>                echo "Already Running!!"
>                exit 1
>            fi
>         fi
>
>
> Cheers
> Niclas

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


RE: Checking PHOENIX_PID for validity

Posted by Daniel Perry <d....@netcase.co.uk>.
I agree.  It's making assumptions like this that caused the problem in the
first place (origional assumption being phoenix.pid exists means it's
running....)

I think my assumption of it running if there's a process under the recorded
id (small chance of it being somthing else) and having "phoenix.home" in it
(very very small chance of it being somthing else).

This is the fist bit of shell script i've ever written, and i'm amazed it
works...
>> (should it not be phoenix\.home really)

Why? (i'm new to this!) is it just escaping? or somthing else?


>>Sounds as if you down have it registered to be stopped during shutdown.

Ok, that was my guess...
But again, being new to this, how do you do that? I thought having it
registered as a service, it would be done for me...

[root@p4-7138 root]# chkconfig --list | grep james
james           0:off   1:off   2:off   3:on    4:on    5:on    6:off

I thought that meant it would be be turned off for halt (0) and reboot (6).

Correct me if i'm wrong :)

Daniel.

-----Original Message-----
From: Christian Andersson [mailto:ca@ofs.no]
Sent: 04 March 2004 06:35
To: James Users List
Subject: Re: Checking PHOENIX_PID for validity


I only see one problem with the one that is in CVS compared to the one
that was offered. The CVS one does not take in account that linux reuses
the process numbers, and therefore there can be some other process that
use the same pid, the one offered tries to take this into account with
the usage of grep phoenix.home  (should it not be phoenix\.home really)

Especially if the main problem is after a unclean shutdown of the james
server and then an reboot of the machine this would be the case.

I have some time ago downloaded a shell script some time ago that was
designed to be used for the init.d (with start,stop,restart,status, etc)
This script has the same problem, and I was baffled before I discovered
it why my servers would not start at a reboot. I ended up having to code
in not just checking that the process was living,but that it was a java
process that had some parameters that identified it as my server.

/Christian

Niclas Hedhman wrote:
> On Thursday 04 March 2004 08:46, Noel J. Bergman wrote:
>
>>>        if [ -f $PHOENIX_PID ]
>>>        then
>>>            phpid=`cat $PHOENIX_PID 2>/dev/null`
>>>            piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
>>>            if [ "$piddata" != "" ]
>>>            then
>>>                    echo "Already Running!!"
>>>                    exit 1
>>>            fi
>>>        fi
>>>
>>>Not sure wether the phoenix team would be interested in doing somthing
>>>similar so as to avoid this kind of problem!
>>
>>I'll cc the Avalon folks so that they can consider it.
>
>
>
> This is already present in Phoenix, at least what is in the CVS.
>
>   start)
>         echo "Starting Phoenix: "
>
>         if [ -f $PHOENIX_PID ]
>         then
>            if ps -p `cat $PHOENIX_PID ` >/dev/null 2>/dev/null
>            then
>                echo "Already Running!!"
>                exit 1
>            fi
>         fi
>
>
> Cheers
> Niclas

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Checking PHOENIX_PID for validity

Posted by Christian Andersson <ca...@ofs.no>.
I only see one problem with the one that is in CVS compared to the one 
that was offered. The CVS one does not take in account that linux reuses 
the process numbers, and therefore there can be some other process that 
use the same pid, the one offered tries to take this into account with 
the usage of grep phoenix.home  (should it not be phoenix\.home really)

Especially if the main problem is after a unclean shutdown of the james 
server and then an reboot of the machine this would be the case.

I have some time ago downloaded a shell script some time ago that was 
designed to be used for the init.d (with start,stop,restart,status, etc)
This script has the same problem, and I was baffled before I discovered 
it why my servers would not start at a reboot. I ended up having to code 
in not just checking that the process was living,but that it was a java 
process that had some parameters that identified it as my server.

/Christian

Niclas Hedhman wrote:
> On Thursday 04 March 2004 08:46, Noel J. Bergman wrote:
> 
>>>        if [ -f $PHOENIX_PID ]
>>>        then
>>>            phpid=`cat $PHOENIX_PID 2>/dev/null`
>>>            piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
>>>            if [ "$piddata" != "" ]
>>>            then
>>>                    echo "Already Running!!"
>>>                    exit 1
>>>            fi
>>>        fi
>>>
>>>Not sure wether the phoenix team would be interested in doing somthing
>>>similar so as to avoid this kind of problem!
>>
>>I'll cc the Avalon folks so that they can consider it.
> 
> 
> 
> This is already present in Phoenix, at least what is in the CVS.
> 
>   start)
>         echo "Starting Phoenix: "
> 
>         if [ -f $PHOENIX_PID ]
>         then
>            if ps -p `cat $PHOENIX_PID ` >/dev/null 2>/dev/null
>            then
>                echo "Already Running!!"
>                exit 1
>            fi
>         fi
> 
> 
> Cheers
> Niclas

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Checking PHOENIX_PID for validity

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 04 March 2004 09:01, Stephen McConnell wrote:

> Off-hand, do you know if this is covered in the merlin scripts as well?

Yes, same mechanism.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Checking PHOENIX_PID for validity

Posted by Stephen McConnell <mc...@apache.org>.
Niclas:

Off-hand, do you know if this is covered in the merlin scripts as well?

Stephen.



Niclas Hedhman wrote:

> On Thursday 04 March 2004 08:46, Noel J. Bergman wrote:
> 
>>>        if [ -f $PHOENIX_PID ]
>>>        then
>>>            phpid=`cat $PHOENIX_PID 2>/dev/null`
>>>            piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
>>>            if [ "$piddata" != "" ]
>>>            then
>>>                    echo "Already Running!!"
>>>                    exit 1
>>>            fi
>>>        fi
>>>
>>>Not sure wether the phoenix team would be interested in doing somthing
>>>similar so as to avoid this kind of problem!
>>
>>I'll cc the Avalon folks so that they can consider it.
> 
> 
> 
> This is already present in Phoenix, at least what is in the CVS.
> 
>   start)
>         echo "Starting Phoenix: "
> 
>         if [ -f $PHOENIX_PID ]
>         then
>            if ps -p `cat $PHOENIX_PID ` >/dev/null 2>/dev/null
>            then
>                echo "Already Running!!"
>                exit 1
>            fi
>         fi
> 
> 
> Cheers
> Niclas


-- 

|------------------------------------------------|
| Magic by Merlin                                |
| Production by Avalon                           |
|                                                |
| http://avalon.apache.org/merlin                |
| http://dpml.net/merlin/distributions/latest    |
|------------------------------------------------|

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Re: Checking PHOENIX_PID for validity

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 04 March 2004 08:46, Noel J. Bergman wrote:
> >         if [ -f $PHOENIX_PID ]
> >         then
> >             phpid=`cat $PHOENIX_PID 2>/dev/null`
> >             piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
> >             if [ "$piddata" != "" ]
> >             then
> >                     echo "Already Running!!"
> >                     exit 1
> >             fi
> >         fi
> >
> > Not sure wether the phoenix team would be interested in doing somthing
> > similar so as to avoid this kind of problem!
>
> I'll cc the Avalon folks so that they can consider it.


This is already present in Phoenix, at least what is in the CVS.

  start)
        echo "Starting Phoenix: "

        if [ -f $PHOENIX_PID ]
        then
           if ps -p `cat $PHOENIX_PID ` >/dev/null 2>/dev/null
           then
               echo "Already Running!!"
               exit 1
           fi
        fi


Cheers
Niclas
-- 
+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Checking PHOENIX_PID for validity

Posted by Niclas Hedhman <ni...@hedhman.org>.
On Thursday 04 March 2004 08:46, Noel J. Bergman wrote:
> >         if [ -f $PHOENIX_PID ]
> >         then
> >             phpid=`cat $PHOENIX_PID 2>/dev/null`
> >             piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
> >             if [ "$piddata" != "" ]
> >             then
> >                     echo "Already Running!!"
> >                     exit 1
> >             fi
> >         fi
> >
> > Not sure wether the phoenix team would be interested in doing somthing
> > similar so as to avoid this kind of problem!
>
> I'll cc the Avalon folks so that they can consider it.


This is already present in Phoenix, at least what is in the CVS.

  start)
        echo "Starting Phoenix: "

        if [ -f $PHOENIX_PID ]
        then
           if ps -p `cat $PHOENIX_PID ` >/dev/null 2>/dev/null
           then
               echo "Already Running!!"
               exit 1
           fi
        fi


Cheers
Niclas
-- 
+---------//-------------------+
|   http://www.bali.ac         |
|  http://niclas.hedhman.org   |
+------//----------------------+

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Checking PHOENIX_PID for validity

Posted by "Noel J. Bergman" <no...@devtech.com>.
> BUT, if i reboot, it doesnt start up properly.

> the phoenix.pid file is getting left behind. So when it
> reboots is doesnt startup - phoenix.sh just says
> it's started!

Sounds as if you down have it registered to be stopped during shutdown.

> alter phoenix.sh so it doesnt just look for the file - it
> verifies that the pid file is a process! This is my first
> attempt at shell coding, so it's a bit unprofessional
> looking, but it works!

> Simply replace the origional code:
>         if [ -f $PHOENIX_PID ]
>         then
>             echo "Already Running!!"
>             exit 1
>         fi

> With:

>         if [ -f $PHOENIX_PID ]
>         then
>             phpid=`cat $PHOENIX_PID 2>/dev/null`
>             piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
>             if [ "$piddata" != "" ]
>             then
>                     echo "Already Running!!"
>                     exit 1
>             fi
>         fi

> Not sure wether the phoenix team would be interested in doing somthing
> similar so as to avoid this kind of problem!

I'll cc the Avalon folks so that they can consider it.

	--- Noel

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org


Checking PHOENIX_PID for validity

Posted by "Noel J. Bergman" <no...@devtech.com>.
> BUT, if i reboot, it doesnt start up properly.

> the phoenix.pid file is getting left behind. So when it
> reboots is doesnt startup - phoenix.sh just says
> it's started!

Sounds as if you down have it registered to be stopped during shutdown.

> alter phoenix.sh so it doesnt just look for the file - it
> verifies that the pid file is a process! This is my first
> attempt at shell coding, so it's a bit unprofessional
> looking, but it works!

> Simply replace the origional code:
>         if [ -f $PHOENIX_PID ]
>         then
>             echo "Already Running!!"
>             exit 1
>         fi

> With:

>         if [ -f $PHOENIX_PID ]
>         then
>             phpid=`cat $PHOENIX_PID 2>/dev/null`
>             piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
>             if [ "$piddata" != "" ]
>             then
>                     echo "Already Running!!"
>                     exit 1
>             fi
>         fi

> Not sure wether the phoenix team would be interested in doing somthing
> similar so as to avoid this kind of problem!

I'll cc the Avalon folks so that they can consider it.

	--- Noel

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: load at bootup

Posted by Daniel Perry <d....@netcase.co.uk>.
This was not fun to solve.  For some reason, the phoenix.pid file is getting
left behind. So when it reboots is doesnt startup - phoenix.sh just says
it's started! i was being fooled by the shell script :(

Anyway, i found a couple of ways round this - simply change
/etc/init.d/james so that the start part deletes the pid file!
but this is sloppy as you could start it twice using service start.

So, the better way is to alter phoenix.sh so it doesnt just look for the
file - it verifies that the pid file is a process! This is my first attempt
at shell coding, so it's a bit unprofessional looking, but it works!

Simply replace the origional code:

        if [ -f $PHOENIX_PID ]
        then
            echo "Already Running!!"
            exit 1
        fi

With:

if [ -f $PHOENIX_PID ]
then
        phpid=`cat $PHOENIX_PID 2>/dev/null`
        piddata=`ps $phpid | grep phoenix.home 2>/dev/null`
        if [ "$piddata" != "" ]
        then
                echo "Already Running!!"
                exit 1
        fi
fi

Not sure wether the phoenix team would be interested in doing somthing
similar so as to avoid this kind of problem!

Daniel.

-----Original Message-----
From: Daniel Perry [mailto:d.perry@netcase.co.uk]
Sent: 03 March 2004 17:55
To: James Users List
Subject: RE: load at bootup


Ok, i went down this service approach (tried both approaches - symlink to
phoenix, and the script noel sent).

It works a treat with "service james start", "service james stop".

BUT, if i reboot, it doesnt start up properly. (this only if it was running
at reboot).

Phoenix does start because if you try to start james again it says it's
already running! However, it isnt listening on any ports. stop it and start
it and it's fine.

Note, it also doesnt generate any log files.

To clarrify:

if james is running fine, and i do:
# shutdown -r now"
when the server reboots, james is running, but doesnt listen!

if james is running fine, and i do:
# service james stop
# shutdown -r now
when the server reboots, james is running, and is listening!

Any ideas? cos i'm stumped!

Thanks,

Daniel.



-----Original Message-----
From: Noel J. Bergman [mailto:noel@devtech.com]
Sent: 01 March 2004 16:29
To: James Users List
Subject: RE: load at bootup


Serge Knystautas wrote:
> Daniel Perry wrote:
> > How would I go about starting james on bootup (Linux)?
> > I'm using Fedora core 1 if that's any help!

> I create a symlink to make James a service, then set that service to
> start at boot time...

> ln -s /usr/local/james/bin/phoenix.sh /etc/init.d/james

> Then put a link to that in rc3.d or however you want to make the service
> start at boot time.

I use the attached.  Place it, or a symlink, in /etc/rc.d/init.d.  Then run

 $ chkconfig --add james

to have it installed.  See "man chkconfig" for other options.  The easy way
to access the scripts is the service command, e.g.,

 $ service james [start | stop | restart]

phoenix.sh has some options not yet supported in this script, but doesn't
integrate with the runlevel level scheme.

	--- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: load at bootup

Posted by Daniel Perry <d....@netcase.co.uk>.
Ok, i went down this service approach (tried both approaches - symlink to
phoenix, and the script noel sent).

It works a treat with "service james start", "service james stop".

BUT, if i reboot, it doesnt start up properly. (this only if it was running
at reboot).

Phoenix does start because if you try to start james again it says it's
already running! However, it isnt listening on any ports. stop it and start
it and it's fine.

Note, it also doesnt generate any log files.

To clarrify:

if james is running fine, and i do:
# shutdown -r now"
when the server reboots, james is running, but doesnt listen!

if james is running fine, and i do:
# service james stop
# shutdown -r now
when the server reboots, james is running, and is listening!

Any ideas? cos i'm stumped!

Thanks,

Daniel.



-----Original Message-----
From: Noel J. Bergman [mailto:noel@devtech.com]
Sent: 01 March 2004 16:29
To: James Users List
Subject: RE: load at bootup


Serge Knystautas wrote:
> Daniel Perry wrote:
> > How would I go about starting james on bootup (Linux)?
> > I'm using Fedora core 1 if that's any help!

> I create a symlink to make James a service, then set that service to
> start at boot time...

> ln -s /usr/local/james/bin/phoenix.sh /etc/init.d/james

> Then put a link to that in rc3.d or however you want to make the service
> start at boot time.

I use the attached.  Place it, or a symlink, in /etc/rc.d/init.d.  Then run

 $ chkconfig --add james

to have it installed.  See "man chkconfig" for other options.  The easy way
to access the scripts is the service command, e.g.,

 $ service james [start | stop | restart]

phoenix.sh has some options not yet supported in this script, but doesn't
integrate with the runlevel level scheme.

	--- Noel


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


RE: load at bootup

Posted by "Noel J. Bergman" <no...@devtech.com>.
Serge Knystautas wrote:
> Daniel Perry wrote:
> > How would I go about starting james on bootup (Linux)?
> > I'm using Fedora core 1 if that's any help!

> I create a symlink to make James a service, then set that service to
> start at boot time...

> ln -s /usr/local/james/bin/phoenix.sh /etc/init.d/james

> Then put a link to that in rc3.d or however you want to make the service
> start at boot time.

I use the attached.  Place it, or a symlink, in /etc/rc.d/init.d.  Then run

 $ chkconfig --add james

to have it installed.  See "man chkconfig" for other options.  The easy way
to access the scripts is the service command, e.g.,

 $ service james [start | stop | restart]

phoenix.sh has some options not yet supported in this script, but doesn't
integrate with the runlevel level scheme.

	--- Noel

Re: load at bootup

Posted by Serge Knystautas <se...@lokitech.com>.
Daniel Perry wrote:
> How would I go about starting james on bootup (Linux)?
> I'm using Fedora core 1 if that's any help!

I create a symlink to make James a service, then set that service to 
start at boot time...

ln -s /usr/local/james/bin/phoenix.sh /etc/init.d/james

Then put a link to that in rc3.d or however you want to make the service 
start at boot time.

-- 
Serge Knystautas
President
Lokitech >> software . strategy . design >> http://www.lokitech.com
p. 301.656.5501
e. sergek@lokitech.com

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org