Some replies inline:

Summary:

I run lots of Tomcats from init scripts on CentOS 6.5. The init script
is . . . ugly. Mine is 500+ lines long.

I'd recommend looking at commons-daemon. Tomcat comes with a script that
can be used as a starting point (daemon.sh)

http://tomcat.apache.org/tomcat-7.0-doc/setup.html#Unix_daemon

On 1/15/2014 8:19 AM, Daniel Mikusa wrote:
On Jan 15, 2014, at 11:01 AM, "Bush, Eddie" <eddie.b...@williams.com>
wrote:



-----Original Message----- From: Daniel Mikusa
[mailto:dmik...@gopivotal.com] Sent: Wednesday, January 15, 2014
9:54 AM To: Tomcat Users List Subject: Re: [tomcat7] rhel 6 -
init.d script works; does not start on reboot

On Jan 15, 2014, at 10:32 AM, "Bush, Eddie"
<eddie.b...@williams.com> wrote:

Howdy, List!

I'm in a bit of a pickle here. I'm a senior dev, and quite good
at that, but for my new client I'm also charged with configuring
our machines. We're running on Tomcat 7, so I grabbed the tgz and
installed it per the instructions.

Everything works great! ... until I reboot the server :) At that
point, everything else comes up, but tomcat does not.

I have removed all logs and rebooted and see nothing notable in
any of the tomcat logs (because, of course, it did not start),
nor can I find anything in syslog or messages. The chkconfig
command reports that the script is configured to run for runlevel
2-5, and I've even inspected the links in rc.d/rc*.d and they are
linked to the init.d script (which is the same danged script that
works interactively via "service tomcat start/stop"!)

Dan> Where did you get the init script from? EB> Off the net
somewhere, initially. I tweaked it to use sudo to change user to
tomcat:tomcat though, and I changed the chkconfig declaration to be
extremely similar to what nginx uses, since that works fine.
chkconfig likes the script, and sets it up in what looks to be
perfect form (comparing to other things). These are pretty standard
scripts though, yes? They basically just delegate to the scripts
distributed with tomcat, which all end up calling catalina.sh :-)

Since it's not standard, can you include it here?  It may be
perfectly fine, but it would be nice to see it regardless.


EB, one of the places I started with was the Tomcat script in the distribution package. Unfortunately, that way lies madness.

Also, can you confirm that the init script is actually being called?
It would be helpful to know how far things get before they break
down.  Since you've said that *no* Tomcat logs get created, I would
expect that things don't get very far.  Maybe add some logging / echo
statements to see what does and doesn't run.


Some things to consider when you're writing your Tomcat script:

1. Do you run with SELinux enabled?

If so, use /sbin/runuser instead of su

2. Do you write your PID files in the standard RedHat locations?

If so, make sure that the directory is read/write for the user Tomcat is run under.

3. Do you write any service startup and shutdown logs?

If so, make sure that the directory is read/write for the user Tomcat is run under.



This may be more of a *nix question than a tomcat question, but I
thought I'd try here first since it is in the context of tomcat
itself.

Thoughts? Suggestions?

Dan> Have you verified that user / permissions are set correct to
run as a service?  Keep in mind that running as a service may be
running Tomcat as a different user. EB> I guess I'm not sure what
you mean here. Apologies. However, I did chown -R tomcat:tomcat on
the entire install. First start after that reminded me I needed to
clean the logs out before expecting it to work :-) but I can now
start this interactively using "sudo service tomcat start" and stop
it, etc. EB> Perhaps I should add that I was raised on Unix,
including being schooled in Unix administration. It's been years,
but I do have a decent amount of experience with Unix, shell
scripting, etc. :-)

Sounds like you've got the general idea of what I was saying here.
Good to know how the permissions are set on the Tomcat directory.

Dan


Dan

I have Google'd myself to death! I'm at my wits end! I'm honestly
at the point of thinking about punting this issue until another
day or possibly resigning to making sure that any workflow which
involves a server reboot includes a step for starting tomcat
(yuck!).

Thanks in advance for any input!

Eddie

There are a lot of other housekeeping things to do before starting up Tomcat. Also, if you have misbehaving applications you'll want to write fairly robust shutdown and restart functions.

However, first things first:

1. Make sure you're using the correct su command (surunner or su)
2. Make sure all of the ancillary directories (see above) have the
   right permissions

When I searched for a startup script a few years ago, I couldn't find one either. I started with the CentOS distribution script, but that quickly became a mess. It dynamically configures ports (for starters) to handle multiple Tomcat instances.

My script works, but it's pretty much a train wreck (I'm not a script writer). It's also a $work product so I would have to ask before posting.

. . . . just my two cents.
/mde/

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to