I'm trying to set up a service, on root, that will automatically start monetdb database after system startup because monetdb doesn't provide such mechanism. I've created /etc/init.d/monetdb
script file:
#!/bin/sh
#
# /etc/init.d/monetdb
# Subsystem file for "MonetDB" starter
#
# chkconfig: 2345 95 05
#
# processname: MonetDB
# pidfile: /var/run/MonetDB.pid
. /etc/init.d/functions
case "$1" in
start)
su - monetka -c ". start.sh"
touch /var/lock/subsys/monetdb
;;
stop)
su - monetka -c ". stop.sh"
rm -f /var/lock/subsys/monetdb
;;
status)
status monetdb
;;
restart|reload|condrestart)
/etc/init.d/monetdb stop
/etc/init.d/monetdb start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
esac
exit 2
I'm using self-made start.sh
and stop.sh
scripts located on monetka
user which are executing fine each time. But when I want to start my service I'm getting an error and the following information:
monetdb.service - SYSV: MonetDB starter
Loaded: loaded (/etc/rc.d/init.d/monetdb)
Active: failed (Result: exit-code) since śro 2015-04-29 14:36:30 CEST; 16min ago
Process: 5390 ExecStart=/etc/rc.d/init.d/monetdb start (code=exited, status=2)
kwi 29 14:36:30 yamny.centOS systemd[1]: Starting SYSV: MonetDB starter...
kwi 29 14:36:30 yamny.centOS su[5391]: (to monetka) root on none
kwi 29 14:36:30 yamny.centOS monetdb[5390]: [śro, 29 kwi 2015, 14:36:30 CEST] MonetDB: dbfarm jest już ur...miona
kwi 29 14:36:30 yamny.centOS monetdb[5390]: [śro, 29 kwi 2015, 14:36:30 CEST] MonetDB: baza demo jest już...miona
kwi 29 14:36:30 yamny.centOS systemd[1]: monetdb.service: control process exited, code=exited status=2
kwi 29 14:36:30 yamny.centOS systemd[1]: Failed to start SYSV: MonetDB starter.
kwi 29 14:36:30 yamny.centOS systemd[1]: Unit monetdb.service entered failed state.
Also, according to the report above, start.sh
script is doing fine (as I stated before).
What I did so far:
- Created
/etc/init.d/monetdb
script on root - Added service with
chkconfig --add monetdb
- Start the service with
systemctl start monetdb.service
Best Answer
Ok, I resolved the problem after deleting some lines from the
/etc/init.d/monetdb
scriptThen added service with
chkconfig --add monetdb
, andsystemctl start/stop monetdb
works like a charm...