streda 26. apríla 2017

How to run JasperServer 6.3.0 via systemd as non-root user on Linux

Prerequisities

  • JasperServer 6.3.0 installed as root into /opt/jasperreports-server-cp-6.3.0/
  • user apache existing in /etc/passwd (if it is not the case, use other user or create one - shell access not needed... subsequent how to is out of scope of this article)
  • tested on CentOS 7, but should be working also on other systems with systemd
Now, let's do it.

Change ownership of installation from root to user

sudo chown -R apache /opt/jasperreports-server-cp-6.3.0/

Create systemd unit configuration file

sudo vim /usr/lib/systemd/system/jasper-server.service

with this content:

[Unit]
Description=Jasper Server 6.3.0
After=syslog.target
After=network.target

[Service]
Type=forking

User=apache
Group=apache

Restart=on-failure
PIDFile=/run/jasper_server.pid
KillMode=mixed
ExecStart=/opt/jasperreports-server-cp-6.3.0/ctlscript.sh start
ExecStop=/opt/jasperreports-server-cp-6.3.0/ctlscript.sh stop
RestartSec=10s

TimeoutSec=900

[Install]
WantedBy=multi-user.target

Daemon reload after later changes of jasper-server.service file:

sudo systemctl daemon-reload

Set it to start-up automatically

sudo chkconfig jasper-server on

Then it could be controlled this way:

sudo service jasper-server start
sudo service jasper-server stop
sudo service jasper-server restart

And checked, if running, this way:

ps -ef | grep jasper

Or checked if running locally (in its default configuration on TCP/HTTP port 8080 of Apache Tomcat):

telnet localhost 8080

Troubleshoot, if needed:

cat /opt/jasperreports-server-cp-6.3.0/apache-tomcat/logs/catalina.out
cat /opt/jasperreports-server-cp-6.3.0/apache-tomcat/logs/catalina.out | grep -i error

If needed, allow JasperServer HTTP port on firewall

CentOS 7 netfilter is controlled by firewall-cmd by default, so when JasperServer / Apache Tomcat is in its default configuration, do this:

sudo firewall-cmd --zone=public --permanent --add-port=8080/tcp
sudo firewall-cmd --reload

Then it should be accessible from remote browser via http://
:8080/jasperserver
.

Enjoy.

2 komentáre:

  1. Update for version 6.4.0 and user nobody: https://docs.google.com/a/system-business.eu/document/d/1TMfkujjI_RCFemYFM35UnADfPmyTwr7GVFbk_1RHtAU/edit?usp=sharing

    OdpovedaťOdstrániť
  2. Thanks!
    Worked for /opt/jasperreports-server-cp-6.4.3/

    OdpovedaťOdstrániť