tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: How can Tomcat be started at boot time as a non-root user
Date Tue, 14 Oct 2014 18:46:02 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Mark,

On 10/14/14 1:21 PM, Mark Eggers wrote:
> Chris,
> 
>> On Tuesday, October 14, 2014 9:47 AM, Christopher Schultz
>> <chris@christopherschultz.net> wrote:
> 
>>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>> 
>> Léa,
>> 
>> On 10/14/14 7:06 AM, Léa Massiot wrote:
>>> My question is about how can Tomcat be started at boot time as
>>> a non-root user.
>>> 
>>> The OS is Debian Wheezy.
>>> 
>>> Below is what I did already:
>>> 
>>> root> chown -R tomcat7.tomcat7 /opt/tomcat7/
>>> 
>>> I created a new file: "/etc/init.d/tomcat7" Owner and owner
>> group:
>>> root Permissions: 755 
>>> ------------------------------------------------------- #!
>>> /bin/sh
>>> 
>>> export JAVA_HOME=/opt/jdk1.7.0_67/ case $1 in
>>> 
>>> start) /bin/bash /opt/tomcat7/bin/startup.sh
>> 
>> Change this to:
>> 
>> su -c "/bin/bash /opt/tomcat7/bin/startup.sh" tomcat7
> 
> You might need to use runuser in the above line if you're running
> SELinux.

Oh, I wasn't aware of that. I don't use SELinux myself.

>> Look at the man page for "su" to see what's going on.
>> 
>> Or you can use jsvc as others have suggested. I think jsvc is
>> probably more robust (because it can restart Tomcat if it dies)
>> but it's a bit more hassle, too.
> 
> I've not tried the jsvc route yet, but I'm sorely tempted
> (especially now with systemd).

I'm interested to hear what you have to say about systemd and how it
relates to Tomcat deployments. systemd can (allegedly) work just fine
with plain-old "init" scripts if you want to use them.

> Writing an init script that takes care of all the issues is
> complicated.

We have one that works just fine under both Debian and RHEL, with
dependencies, etc. It's a bare-bones script that basically just calls
our ant build script which understands how to launch Tomcat with all
the right environment variables set. We do this because we have
multiple VMs running -- one per webapp -- and everything is configured
in one place. Basically, "/etc/init.d/webapp start" for us just
translates into "ant tomcat-start", etc.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJUPW9qAAoJEBzwKT+lPKRY3twQAL4x/Msm1XTSlRn1/Llzx7Ve
4WHaq+kFAk1Z83acpq/elRbNA+FU2iChnl7r4ICKk03iInL9kDS36M41c+v52sH6
NcM+oOHJv7UNywfnEdUpKD2eUIOrvU7kp+Y3SgutOPOanzOwprZSPlDuIJVJnAeq
i0W4yKl/lVVDET+71laUHqLh8arIv/Oa/Yq40L0DdGsOADHUuasND/CcTRwfkzrM
MdGRuY69AevI5htZDealPcUmn7TJxmmTE/kI2R7ubvc68F2E0lXeBMVgXMS1daGI
29wg74LvFAnssYVDQffSh0ClpVVkoHUPAhnAMU0XCWe2UataW1DkCG/6nvJwZv8Z
FRBy/yeyEOZnL1z46WUIcIZZhLqP358j80dCRsFhr4ESngLVO75xvup/uzy9SN9q
UFTJya5G1RZWUKk/6H6XaMO/8diExXBfWlDI7IhtVFgx1b/5iT+qhhI8WUeMtDDv
ttp8jduHmZRfx7EsHtkhMHdbpULvx8YTpcIhIoB75vCwTMDxuqNY38USavhLSHwt
qHqZGMPQKok6/tsGSDOHK+1twx8isqhp0LUt7eJEvCsyjqTL7B8cPBoCaF+7fDV8
vgUTpmKC14PzA8C/z3/Xg+kNA1D7vaKHLpO2Rp9JmD0PSCQJ/iQ5shGGML7XcdMA
urgEHwBHccjxU/yNHDhv
=sUik
-----END PGP SIGNATURE-----

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


Mime
View raw message