ich nutze hier einen BeagleboneBlack mit installiertem Wheezy. Bin noch sehr neu in Linux, arbeite mich aber gerade ein. Natürlich, wie sollte es auch anders sein, wende ich mich mit einem Problem an Euch.
Ich habe hier ein Python-Script, daß Messages vom CAN-Bus entgegen nimmt und in eine MySQL-Datenbank schreibt. Das klappt auch alles einwandfrei. Jetzt wollte ich das Script als Dienst über einen init.d-Eintrag starten. Nach kleineren Problemen klappt auch das. Wenn ich danach allerdings den Status, mit
Code: Alles auswählen
systemctl status canservice.service
Code: Alles auswählen
canservice.service - LSB: Receives messages from the CAN-bus and store it into a database
Loaded: loaded (/etc/init.d/canservice.sh)
Active: active (exited) since Wed, 20 Aug 2014 13:27:25 +0200; 3 weeks and 3 days ago
Process: 422 ExecStart=/etc/init.d/canservice.sh start (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/canservice.service
Code: Alles auswählen
systemctl restart canservice.service
Wieso ist das exited anstatt running?
Könnt Ihr mir den ein- oder anderen Tipp zu meinem Problem geben?
Jürgen
Achso, hier noch das Start - Stop - Script. Habe es mir aus einem Tut kopiert und angepasst.
Code: Alles auswählen
#!/bin/bash
### BEGIN INIT INFO
# Provides: canservice
# Required-Start: $all
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Receives messages from the CAN-bus and store it into a database
# Description: Python-script receives messages from the CAN-bus and put it into a database
### END INIT INFO
# Change the next 3 lines to suit where you install your script and what you want to call it
DIR=/home/counter/canservice
DAEMON=$DIR/canservice.py
DAEMON_NAME=canservice
# Add any command line options for your daemon here
DAEMON_OPTS=""
# This next line determines what user the script runs as.
# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
DAEMON_USER=root
# The process ID of the script when it runs is stored here:
PIDFILE=/var/run/$DAEMON_NAME.pid
. /lib/lsb/init-functions
do_start () {
log_daemon_msg "Starting system $DAEMON_NAME daemon"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS
log_end_msg $?
}
do_stop () {
log_daemon_msg "Stopping system $DAEMON_NAME daemon"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
}
case "$1" in
start|stop)
do_${1}
;;
restart|reload|force-reload)
do_stop
do_start
;;
status)
status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
exit 1
;;
esac
exit 0