Quantcast

Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

Douglas Landau
Hi All,

Sorry for the dumb question.  I've installed CentOS-7.2, Java-1.8, MySQL 5.7, Tomcat 9.0.0, XWiki 8.4.3.  I've built jsvc and have created a startup script, catalina_start.   But now I want a stop script, and to integrate with systemctl/systemd on CentOS-7.  I see the page at https://www.weblab360.com/User:xltran/App/xWiki/Installation/CentOS_7 which shows the form of the systemd script /etc/systemd/system.xwiki.service:
-------------------------------------------------------
[Unit]
Description=xWiki Service
After=network.target

[Service]
Type=simple
User=root
ExecStart=/bin/bash /usr/local/xwiki/start_xwiki.sh -p 80
ExecStop=/bin/bash /usr/local/xwiki/stop_xwiki.sh -p 80
Restart=on-abort

[Install]
WantedBy=multi-user.target
-----------------------------------------------

But, I have no /usr/local/xwiki and thus no start-xwiki.sh and stop_xwiki.sh.  I installed from .war and don't see those scripts in /opt/apache-tomcat-9.0.0.M15/webapps/xwiki/.  

Okay, well, I have a catalina_start that works, so I can use that.  But for the stop?  When I say "$CATALINA_HOME/bin/catalina.sh stop" or "$CATALINA_HOME/bin/shutdown.sh", I get the following:
[root@pwswiki10 opt]# $CATALINA_HOME/bin/shutdown.sh
Using CATALINA_BASE:   /opt/apache-tomcat-9.0.0.M15
Using CATALINA_HOME:   /opt/apache-tomcat-9.0.0.M15
Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.0.M15/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_25
Using CLASSPATH:       /opt/apache-tomcat-9.0.0.M15/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M15/bin/tomcat-juli.jar
Mar 01, 2017 5:12:16 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact localhost:8005. Tomcat may not be running.
Mar 01, 2017 5:12:16 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at java.net.Socket.connect(Socket.java:538)
        at java.net.Socket.<init>(Socket.java:434)
        at java.net.Socket.<init>(Socket.java:211)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:476)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:408)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:497)


What have I neglected to do?
Thanks in advance
Doug




The information contained in this transmission may contain West Marine proprietary, confidential and/or privileged
information.  It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are
hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited.
If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original
message. To reply to our email administrator directly, please send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

Douglas Landau
Okay.  I found the line with port 8005 in server.xml:
./conf/server.xml:<Server port="8005" shutdown="SHUTDOWN">

... and changed it to 8080.   However, altho $CTALINA_HOME/bin/shutdown.sh now runs, it doesn't seem to shut it down.  Furthermore there are two of them running. PIDs 1597 and 1598.  Is that correct?    TIA.  
/var/run/jsvc.pid shows only 1598.

root      1597  0.0  0.0   8560   336 ?        Ss   17:30   0:00 jsvc.exec -classpath /opt/apache-tomcat-9.0.0.M15/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M15/bin/tomcat-juli.jar -outfile /opt/apache-tomcat-9.0.0.M15/logs/catalina.out -errfile /opt/apache-tomcat-9.0.0.M15/logs/catalina.err -Dcatalina.home=/opt/apache-tomcat-9.0.0.M15 -Dcatalina.base=/opt/apache-tomcat-9.0.0.M15 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/opt/apache-tomcat-9.0.0.M15/conf/logging.properties org.apache.catalina.startup.Bootstrap

root      1598 71.2  2.0 2986964 80708 ?       Sl   17:30   0:02 jsvc.exec -classpath /opt/apache-tomcat-9.0.0.M15/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M15/bin/tomcat-juli.jar -outfile /opt/apache-tomcat-9.0.0.M15/logs/catalina.out -errfile /opt/apache-tomcat-9.0.0.M15/logs/catalina.err -Dcatalina.home=/opt/apache-tomcat-9.0.0.M15 -Dcatalina.base=/opt/apache-tomcat-9.0.0.M15 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/opt/apache-tomcat-9.0.0.M15/conf/logging.properties org.apache.catalina.startup.Bootstrap
root      1613  0.0  0.0 161352  1884 pts/0    R+   17:31   0:00 ps -auxww
[root@pwswiki10 opt]# more catalina_start
CATALINA_BASE=$CATALINA_HOME
CATALINA_OPTS="-Xmx1024m -XX:MaxPermSize=192m"

export JAVA_OPTS="${JAVA_OPTS} -Djava.awt.headless=true"

cd $CATALINA_HOME
./bin/jsvc \
    -classpath $CATALINA_HOME/bin/bootstrap.jar:$CATALINA_HOME/bin/tomcat-juli.j
ar \
    -outfile $CATALINA_BASE/logs/catalina.out \
    -errfile $CATALINA_BASE/logs/catalina.err \
    -Dcatalina.home=$CATALINA_HOME \
    -Dcatalina.base=$CATALINA_BASE \
    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager \
    -Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties \
    org.apache.catalina.startup.Bootstrap
export PERL_MB_OPT="--install_base /root/perl5";
export PERL_MM_OPT="INSTALL_BASE=/root/perl5";
[root@pwswiki10 opt]#

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

-----Original Message-----
From: users [mailto:[hidden email]] On Behalf Of Douglas Landau
Sent: Wednesday, March 01, 2017 5:14 PM
To: XWiki Users
Subject: [xwiki-users] Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

Hi All,

Sorry for the dumb question.  I've installed CentOS-7.2, Java-1.8, MySQL 5.7, Tomcat 9.0.0, XWiki 8.4.3.  I've built jsvc and have created a startup script, catalina_start.   But now I want a stop script, and to integrate with systemctl/systemd on CentOS-7.  I see the page at https://www.weblab360.com/User:xltran/App/xWiki/Installation/CentOS_7 which shows the form of the systemd script /etc/systemd/system.xwiki.service:
-------------------------------------------------------
[Unit]
Description=xWiki Service
After=network.target

[Service]
Type=simple
User=root
ExecStart=/bin/bash /usr/local/xwiki/start_xwiki.sh -p 80 ExecStop=/bin/bash /usr/local/xwiki/stop_xwiki.sh -p 80 Restart=on-abort

[Install]
WantedBy=multi-user.target
-----------------------------------------------

But, I have no /usr/local/xwiki and thus no start-xwiki.sh and stop_xwiki.sh.  I installed from .war and don't see those scripts in /opt/apache-tomcat-9.0.0.M15/webapps/xwiki/.  

Okay, well, I have a catalina_start that works, so I can use that.  But for the stop?  When I say "$CATALINA_HOME/bin/catalina.sh stop" or "$CATALINA_HOME/bin/shutdown.sh", I get the following:
[root@pwswiki10 opt]# $CATALINA_HOME/bin/shutdown.sh
Using CATALINA_BASE:   /opt/apache-tomcat-9.0.0.M15
Using CATALINA_HOME:   /opt/apache-tomcat-9.0.0.M15
Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.0.M15/temp
Using JRE_HOME:        /usr/java/jdk1.8.0_25
Using CLASSPATH:       /opt/apache-tomcat-9.0.0.M15/bin/bootstrap.jar:/opt/apache-tomcat-9.0.0.M15/bin/tomcat-juli.jar
Mar 01, 2017 5:12:16 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Could not contact localhost:8005. Tomcat may not be running.
Mar 01, 2017 5:12:16 PM org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:589)
        at java.net.Socket.connect(Socket.java:538)
        at java.net.Socket.<init>(Socket.java:434)
        at java.net.Socket.<init>(Socket.java:211)
        at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:476)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:408)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:497)


What have I neglected to do?
Thanks in advance
Doug




The information contained in this transmission may contain West Marine proprietary, confidential and/or privileged information.  It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. To reply to our email administrator directly, please send an email to [hidden email].

The information contained in this transmission may contain West Marine proprietary, confidential and/or privileged
information.  It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are
hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited.
If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original
message. To reply to our email administrator directly, please send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

rez_spb
Hello,

Port in <server> property is a Tomcat system port used for shutdown, it should not be confused with a port Tomcat service connector listens on (client connection port like 80, 8080, 443 etc). So changing it to 8080 is not what you should've done, I think.

Two instances are most likely due to first failed attempt to stop Tomcat, after which you've started it again. I have seen the similar issue.

What you'd probably want to do is to killall java, then change port back to 8005, start Tomcat and wait till it's up and running, check that it listens on port 8005 and it is the correct Tomcat (in case you have several of them you should use other port, but not 8080 as it is used for client connections).
My example with 2 tomcats running:
tomcat7@pandora:~$ netstat -an | grep 8[0-9]05
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN
tcp6       0      0 127.0.0.1:8105          :::*                    LISTEN

After this you'd probably want to (manually) send a signal (default is sending 'SHUTDOWN') to this port and wait for what happens. I bet catalina.out log will have some info on whether the shutdown was successful.

One more tip: you actually shouldn't run Tomcat as root, this could get messy pretty fast.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

Douglas Landau

>Port in <server> property is a Tomcat system port used for shutdown, it should not be confused with a port Tomcat service connector listens on (client connection port like 80, 8080, 443 etc). So changing it to 8080 is not what you should've done, I think.

Thanks.  I changed it back to 8005.  But when I start up it is still not listening on 8005, and so the shutdown script does not work.  What have I overlooked/do I have to do to enable port 8005 shutdown?

Thanks
Doug


The information contained in this transmission may contain West Marine proprietary, confidential and/or privileged
information.  It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are
hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited.
If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original
message. To reply to our email administrator directly, please send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

Douglas Landau
In reply to this post by rez_spb

>One more tip: you actually shouldn't run Tomcat as root, this could get messy pretty fast.
Thanks!

- In fact I installed Tomcat and xwiki as root.  I guess someone else should own the files?
- I would like to run tomcat/xwiki on port 80.  Do I need to run as root to do that?  Do I need to set up some privsep user such that it starts as root and then SU's to a lesser user, like ssh does?

Thx again.
Doug



--
View this message in context: http://xwiki.475771.n2.nabble.com/Stopping-Xwiki-8-4-3-Tomcat-9-0-and-integrating-with-systemctl-tp7602905p7602907.html
Sent from the XWiki- Users mailing list archive at Nabble.com.

The information contained in this transmission may contain West Marine proprietary, confidential and/or privileged
information.  It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are
hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited.
If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original
message. To reply to our email administrator directly, please send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

Thomas Mortagne
Administrator
On Thu, Mar 9, 2017 at 12:11 AM, Douglas Landau <[hidden email]> wrote:
>
>>One more tip: you actually shouldn't run Tomcat as root, this could get messy pretty fast.
> Thanks!
>
> - In fact I installed Tomcat and xwiki as root.  I guess someone else should own the files?

> - I would like to run tomcat/xwiki on port 80.  Do I need to run as root to do that?  Do I need to set up some privsep user such that it starts as root and then SU's to a lesser user, like ssh does?

It's indeed possible Tomcat require root to use port 80. At least on
Linux. Usually what most people do is put Apache on Nginx in front of
Tomcat on port 80 and keep Tomcat on port 8080.

>
> Thx again.
> Doug
>
>
>
> --
> View this message in context: http://xwiki.475771.n2.nabble.com/Stopping-Xwiki-8-4-3-Tomcat-9-0-and-integrating-with-systemctl-tp7602905p7602907.html
> Sent from the XWiki- Users mailing list archive at Nabble.com.
>
> The information contained in this transmission may contain West Marine proprietary, confidential and/or privileged
>
> information.  It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are
>
> hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited.
>
> If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original
>
> message. To reply to our email administrator directly, please send an email to [hidden email].



--
Thomas Mortagne
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

Douglas Landau
Thanks.   Sorry to continue with the dumb questions, but that said,:
- I see that I don't have the ability to run Tomcat as myself, having installed it as root and not changed any permissions.    I spose that most people create a new, local, user "xwiki" or "tomcat_user", and install and run the software as that user?
- Do most people run Tomcat or something else?
- Do most people install Xwiki from WAR or using the standalone?

Thinkin I should start over ..

-----Original Message-----
From: users [mailto:[hidden email]] On Behalf Of Thomas Mortagne
Sent: Wednesday, March 08, 2017 11:47 PM
To: XWiki Users
Subject: Re: [xwiki-users] Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

On Thu, Mar 9, 2017 at 12:11 AM, Douglas Landau <[hidden email]> wrote:
>
>>One more tip: you actually shouldn't run Tomcat as root, this could get messy pretty fast.
> Thanks!
>
> - In fact I installed Tomcat and xwiki as root.  I guess someone else should own the files?

> - I would like to run tomcat/xwiki on port 80.  Do I need to run as root to do that?  Do I need to set up some privsep user such that it starts as root and then SU's to a lesser user, like ssh does?

It's indeed possible Tomcat require root to use port 80. At least on Linux. Usually what most people do is put Apache on Nginx in front of Tomcat on port 80 and keep Tomcat on port 8080.

>
> Thx again.
> Doug
>
>
>
> --
> View this message in context:
> http://xwiki.475771.n2.nabble.com/Stopping-Xwiki-8-4-3-Tomcat-9-0-and-
> integrating-with-systemctl-tp7602905p7602907.html
> Sent from the XWiki- Users mailing list archive at Nabble.com.
>
> The information contained in this transmission may contain West Marine
> proprietary, confidential and/or privileged
>
> information.  It is intended only for the use of the person(s) named
> above. If you are not the intended recipient, you are
>
> hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited.
>
> If you are not the intended recipient, please contact the sender by
> reply email and destroy all copies of the original
>
> message. To reply to our email administrator directly, please send an email to [hidden email].



--
Thomas Mortagne

The information contained in this transmission may contain West Marine proprietary, confidential and/or privileged
information.  It is intended only for the use of the person(s) named above. If you are not the intended recipient, you are
hereby notified that any review, dissemination, distribution or duplication of this communication is strictly prohibited.
If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original
message. To reply to our email administrator directly, please send an email to [hidden email].
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating with systemctl

RicardoJulioRodriguezFernandez
Hi, Douglas!

On Thu, Mar 9, 2017 at 8:05 PM Douglas Landau <[hidden email]>
wrote:

> Thanks.   Sorry to continue with the dumb questions, but that said,:
> - I see that I don't have the ability to run Tomcat as myself, having
> installed it as root and not changed any permissions.    I spose that most
> people create a new, local, user "xwiki" or "tomcat_user", and install and
> run the software as that user?
> - Do most people run Tomcat or something else?
> - Do most people install Xwiki from WAR or using the standalone?
>

I don't think your question is a dumb question but, in fact, it is not a
single question! I do think you are doing a mega-mix!

People run a lot of different combination of OS, application server, web
server and databases. Our production servers run older versions than your,
but I do think our installation could be an example. Here you have some
links that were usefull for me more than two years ago...

http://atriumkm.idisantiago.es/bin/ICT/InstallingTomcat

I think I remember last two comments dated on 2014/08/04 09:22 and 2014/11/29
08:56 were the ones leading us to the configuration of our current Tomcat
installation running two XWiki instances: a plain old XWiki Enterprise
2.4.30451 and a newer XWiki Enterprise 7.3 one.

I'm now solving several issues with a brand new XWiki 9.2.2 on Tomcat
9.0.0.M17 and MySQL; in this case on a Mac OS X box.

That's why I'm really interested in understanding your issue!

Please, don't forget to read more than ten times the XWiki pages related
with the installation on the container you have choosen and make comments
and send question about their contents!


> Thinkin I should start over ..
>

Cheers!


>
> -----Original Message-----
> From: users [mailto:[hidden email]] On Behalf Of Thomas Mortagne
> Sent: Wednesday, March 08, 2017 11:47 PM
> To: XWiki Users
> Subject: Re: [xwiki-users] Stopping Xwiki-8.4.3/Tomcat-9.0 and integrating
> with systemctl
>
> On Thu, Mar 9, 2017 at 12:11 AM, Douglas Landau <[hidden email]>
> wrote:
> >
> >>One more tip: you actually shouldn't run Tomcat as root, this could get
> messy pretty fast.
> > Thanks!
> >
> > - In fact I installed Tomcat and xwiki as root.  I guess someone else
> should own the files?
>
> > - I would like to run tomcat/xwiki on port 80.  Do I need to run as root
> to do that?  Do I need to set up some privsep user such that it starts as
> root and then SU's to a lesser user, like ssh does?
>
> It's indeed possible Tomcat require root to use port 80. At least on
> Linux. Usually what most people do is put Apache on Nginx in front of
> Tomcat on port 80 and keep Tomcat on port 8080.
>
> >
> > Thx again.
> > Doug
> >
> >
> >
> > --
> > View this message in context:
> > http://xwiki.475771.n2.nabble.com/Stopping-Xwiki-8-4-3-Tomcat-9-0-and-
> > integrating-with-systemctl-tp7602905p7602907.html
> > Sent from the XWiki- Users mailing list archive at Nabble.com.
> >
> > The information contained in this transmission may contain West Marine
> > proprietary, confidential and/or privileged
> >
> > information.  It is intended only for the use of the person(s) named
> > above. If you are not the intended recipient, you are
> >
> > hereby notified that any review, dissemination, distribution or
> duplication of this communication is strictly prohibited.
> >
> > If you are not the intended recipient, please contact the sender by
> > reply email and destroy all copies of the original
> >
> > message. To reply to our email administrator directly, please send an
> email to [hidden email].
>
>
>
> --
> Thomas Mortagne
>
> The information contained in this transmission may contain West Marine
> proprietary, confidential and/or privileged
> information.  It is intended only for the use of the person(s) named
> above. If you are not the intended recipient, you are
> hereby notified that any review, dissemination, distribution or
> duplication of this communication is strictly prohibited.
> If you are not the intended recipient, please contact the sender by reply
> email and destroy all copies of the original
> message. To reply to our email administrator directly, please send an
> email to [hidden email].
>
--
Ricardo Rodríguez
Research Management and Promotion Technician
Technical Secretariat
Health Research Institute of Santiago de Compostela (IDIS)
http://www.idisantiago.es
Loading...