Jasper Reports

JasperReports: Server Automatic Start

Souce: http://community.jaspersoft.com/questions/541044/auto-start-boot

 

Those scripts won’t work as supplied as the paths are all wrong, and the bundle doesn’t include apache anyway (it’s supplied by the OS). Since jasper does have a functional control script, I’ve rewritten the control script to use it and match the paths used by the install bundle, saved it at /etc/init.d/jasperserver and given it execute permissions:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          jasperserver
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start JasperServer at boot time
# Description:       Enable service provided by JasperServer.
### END INIT INFO

JASPER_HOME="/opt/jasperreports-server-cp-7.1.0/"

case "$1" in
  start)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      echo "Starting JasperServer"
      $JASPER_HOME/ctlscript.sh start
    fi
    ;;
  stop)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      echo "Stopping JasperServer"
      $JASPER_HOME/ctlscript.sh stop
    fi
    ;;
  restart)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      echo "Restarting JasperServer"
      $JASPER_HOME/ctlscript.sh restart
    fi
    ;;
  status)
    if [ -f $JASPER_HOME/ctlscript.sh ]; then
      $JASPER_HOME/ctlscript.sh status
    fi
    ;;
  *)
    echo $"Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac

I don’t think it’s a good idea to name tomcat separately in this context as it may get confused with any system supplied script, and the jasper script controls more than one thing. I think the jasper control script would actually work directly as an init.d script, however it supports many other options that are possibly hazardous to normal operations, so this wrapper limits access to start/stop/restart/status.

The correct way to create startup links is not to manually create them as that article suggests, but to use one of the utilities provided by the OS to do it. Tomcat doesn’t need apache in order to run jasper, though if you’re proxying via apache (in order to avoid the :8080 URL) it won’t work until apache is running, but since it’s not a functional requirement I don’t think it’s necessary to describe it as a startup dependency as it will work if apache is started before or after tomcat, so the default startup priority should work fine. On Debian/Ubuntu you would do this:

update-rc.d jasperserver defaults

Controlling Jasper can then be done like this:

service jasperserver start
service jasperserver stop
service jasperserver restart
service jasperserver status

The headers in the startup script are for the upstart startup system that has been the recommended method on Ubuntu for the last few years.

If you list an OS as ‘supported’, I would really expect this to be there out of the box. Mind you, this is oddly common amongst Java apps – none of Atlassian’s products have sensible startup scripts.

BTW the FCKEditor in this forum is an old and buggy version. Any chance of an update? I had to edit this post’s source in an external editor to stop it messing it up.

Leave a Reply

Your email address will not be published. Required fields are marked *