Autostart openolat after rebooting ubuntu server

26 views
Skip to first unread message

Hanspeter Vogt

unread,
Jan 7, 2020, 8:13:12 AM1/7/20
to OpenOlat
Hi all

I continued finding a solution to startup openolat after rebooting ubuntu server without login.

 I found a lot of tips and hints on internet:
- implementing a service with systemctl
- rc.local solution
- @reboot calling a shell script in user crontab

Any of the mentioned solution raises in  different problems.

I hope to get some feedback / help on this problem.

/Hanspeter

Florian Gnägi

unread,
Jan 7, 2020, 9:51:26 AM1/7/20
to open...@googlegroups.com
Hi /Hanspeter

It is really not possible to help without knowing what exactly is not working. The general advice would be to use google to lookup how your linux distro preferably launches the tomcat start script for you using the correct user ID and shell. Just make sure Postgres did successfully stat prior to starting OpenOlat. 

However, you can also argue that you should better not start up automatically at all. If you system crashed you should first investigate what caused the crash and check FS etc. If you update your system you also want to perform some checks on FS and DB first before starting a high level service. And I see no other reason to reboot a system nowadays. In our cloud infrastructure for example we do not automatically start OpenOlat on booting the OS. We do it manually with a script that makes sure the boot process of many instances does not exhaust resources in a way that the entire system is blocked and we monitor this process. 

Cheers
Florian

--
--
Sie erhalten diese Nachricht, weil Sie Mitglied sind von Google
Groups-Gruppe "OpenOlat".
Für das Erstellen von Beiträgen in dieser Gruppe senden Sie eine E-Mail
an open...@googlegroups.com
Um sich von dieser Gruppe abzumelden, senden Sie eine E-Mail an
openolat+u...@googlegroups.com
Weitere Optionen finden Sie in dieser Gruppe unter
http://groups.google.com/group/openolat?hl=de
-------------------------------------------------------------------------------------------------------------------
OpenOlat - infinite learning - http://www.openolat.org
---
You received this message because you are subscribed to the Google Groups "OpenOlat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openolat+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openolat/3f4b8bcf-ec03-457f-830e-688aac125e69%40googlegroups.com.

--------------------------------------------------------------------
professional services for the e-learning system OpenOLAT
hosting - operating - support - development - mobile - consulting
--------------------------------------------------------------------
frentix  GmbH
Florian Gnägi, Geschäftsführer
Okenstrasse 6
CH-8037 Zürich, Switzerland


Find me on wire skype twitter xing linkedin 
--------------------------------------------------------------------

Message has been deleted

Hans

unread,
Mar 29, 2020, 3:55:26 AM3/29/20
to OpenOlat
To autostart openolat it needs a daemon script in /etc/init.d. It is neccesarry to start it as the user of openolat, therefore you need to adjust the environment variables already in the daemon script.

create daemon script

sudo nano /etc/init.d/openolat

#!/bin/bash
export CATALINA_BASE=/home/openolat
export CATALINA_HOME=/home/openolat/tomcat
export JRE_HOME=/home/openolat/jre
export CATALINA_PID="$CATALINA_BASE/bin/catalina.pid"
USER=openolat
START=$CATALINA_HOME/bin/startup.sh
STOP=$CATALINA_HOME/bin/shutdown.sh
ERROR=0
 
case "$1" in
 start)
            echo $"Starting Tomcat"
            start-stop-daemon --start --chuid $USER --pidfile "$CATALINA_PID" --start --exec "$START"

            ;;
 stop)
           echo $"Stopping Tomcat"
           start-stop-daemon --start --chuid $USER --pidfile "$CATALINA_PID" --start --exec "$STOP"
           ;;
 restart)
           DAEMON=$CATALINA_HOME/bin/shutdown.sh
           start-stop-daemon --start --chuid $USER --pidfile "$CATALINA_PID" --start --exec "$START"
           start-stop-daemon --start --chuid $USER --pidfile "$CATALINA_PID" --start --exec "$STOP"
            ;;
 *)
         echo $"Usage: $0 {start|stop|restart}"
 exit 1
 ;;
esac

exit $ERROR

change permission:
chmod 755 /etc/init.d/openolat

invoke autostart:
update-rc.d openolat defaults

manual start/stop:
service openolat start
service openolat stop

sources: here
and here
and here

good luck

Hans

Hans

unread,
Mar 29, 2020, 5:22:45 AM3/29/20
to OpenOlat
At the top of the /etc/init.d/openolat is something missing:

here is correct script:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          openolat
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts openolat server
# Description:       starts openolat
### END INIT INFO
Reply all
Reply to author
Forward
0 new messages