mw2000
Anmeldungsdatum: 27. Dezember 2009
Beiträge: 90
|
Hallo zusammen, ich versuche mit systemd meinen twonky mediacenter zu starten. Leider komme ich nicht weiter. Ziel ist es den twonky bei jedem Reboot automatisch zu starten. Folgendes script startet manuell zuverlässig den twonky server. |
matthias@naxos:~$ /usr/local/twonky/twonky.sh start
Starting /usr/local/twonky/twonkystarter ...
matthias@naxos:~$
For image conversion and scaling the TwonkyServer utilizes ImageMagick. For details on the license please see /usr/local/twonky/cgi-bin/convert-readme.txt
Twonky Version 8.5.1
Snapshot Twonky_8.5.1_20180521 TA:c5bd20adecfd43fcf30c90b1271d424f773c1060
Platform x86-64_gcc520_glibc222_2__twonkyforum-x86-64-glibc-2.22
|
Nun habe ich eine eigene systemd unit twonky.service erstellt 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | # Edit Matthias
# This unit gets pulled automatically into multi-user.target by
# systemd an starts the twonky mediaseerver
[Unit]
Description=twonky starter
Documentation=http://naxos/
#ConditionFileIsExecutable=/usr/local/twonky/twonkystarter
#After=network.target
[Service]
Type=simple
ExecStart=/usr/local/twonky/twonky.sh start
#TimeoutSec=0
#RemainAfterExit=no
RestartSec=30
Restart=always
[Install]
WantedBy=multi-user.target
#WantedBy=network-online.target
|
Danach folgende Befehle ausgeführt: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | matthias@naxos:~$ sudo systemctl daemon-reload
matthias@naxos:~$ sudo systemctl is-enabled twonky
enabled
matthias@naxos:~$ sudo systemctl status twonky.service
● twonky.service - twonky starter
Loaded: loaded (/etc/systemd/system/twonky.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Tue 2018-08-21 22:12:13 CEST; 12s ago
Docs: http://naxos/
Process: 1870 ExecStart=/usr/local/twonky/twonky.sh start (code=exited, status=13)
Main PID: 1870 (code=exited, status=13)
matthias@naxos:~$ sudo systemctl start twonky.service
matthias@naxos:~$ sudo systemctl status twonky.service
● twonky.service - twonky starter
Loaded: loaded (/etc/systemd/system/twonky.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Tue 2018-08-21 22:13:17 CEST; 10s ago
Docs: http://naxos/
Process: 1890 ExecStart=/usr/local/twonky/twonky.sh start (code=exited, status=13)
Main PID: 1890 (code=exited, status=13)
matthias@naxos:~$
|
Soweit scheint die Unit ja zu laufen, nur wird der twonky.server nicht gestartet.
Habt Ihr eine Tipp warum diese Unit den Befehl nicht ausführt? Danke Matthias
|
Kellerkind_2009
Anmeldungsdatum: 26. November 2009
Beiträge: 19617
Wohnort: Schleswig-Holstein
|
Noop der Läuft nicht Process: 1890 ExecStart=/usr/local/twonky/twonky.sh start (code=exited, status=13) Mit viel Glück siehst du hier warum journalctl -xe
|
seahawk1986
Anmeldungsdatum: 27. Oktober 2006
Beiträge: 11243
Wohnort: München
|
Was macht denn /usr/local/twonky/twonky.sh start genau? Das Skript scheint sich direkt mit dem Exit-Code 13 zu verabschieden. Wenn du Systemd mit dem Type=simple laufen lässt, erwartet es, dass das im Exec-Befehl gestarte Programm dauerhaft läuft und kümmert sich um die Prozesskontrolle.
|
mw2000
(Themenstarter)
Anmeldungsdatum: 27. Dezember 2009
Beiträge: 90
|
Hi, das script twonky.sh startet den twonky mediacenter 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264 | !/bin/sh
#
# MediaServer Control File written by Itzchak Rehberg
# Modified for fedora/redhat by Landon Bradshaw <phazeforward@gmail.com>
# Adapted to Twonky 3.0 by TwonkyVision GmbH
# Adapted to Twonky 4.0 by TwonkyVision GmbH
# Adapted to Twonky 5.0 by PacketVideo
#
# This script is intended for SuSE and Fedora systems.
#
#
###############################################################################
#
### BEGIN INIT INFO
# Provides: twonkyserver
# Required-Start: $network $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Twonky UPnP server
### END INIT INFO
#
# Comments to support chkconfig on RedHat/Fedora Linux
# chkconfig: 345 71 29
# description: Twonky UPnP server
#
#==================================================================[ Setup ]===
WORKDIR1="/usr/local/twonky"
WORKDIR2="`dirname $0`"
PIDFILE=/var/run/mediaserver.pid
#change this to 0 to disable the twonky proxy service
START_PROXY=0
#change this to 0 to disable the twonky tuner service
START_TUNER=0
#=================================================================[ Script ]===
stop_support_daemon() {
SUPPORT_DAEMON=$1
if [ "${SUPPORT_DAEMON}" = "" ]; then
return 12
fi
if [ "${SUPPORT_DAEMON}" = "none" ]; then
return 13
fi
echo "Stopping ${SUPPORT_DAEMON}"
killall ${SUPPORT_DAEMON}
}
check_support_daemon() {
SUPPORT_DAEMON=$1
if [ "${SUPPORT_DAEMON}" = "" ]; then
return 12
fi
if [ "${SUPPORT_DAEMON}" = "none" ]; then
return 13
fi
SD_PID=`ps --no-headers -o pid -C ${SUPPORT_DAEMON}`
if [ "${SD_PID}" = "" ]; then
return 0
else
return 1
fi
}
start_support_daemon() {
SUPPORT_DAEMON=$1
SUPPORT_DAEMON_WORKDIR=$2
if [ "${SUPPORT_DAEMON}" = "" ]; then
return 12
fi
if [ "${SUPPORT_DAEMON}" = "none" ]; then
return 13
fi
check_support_daemon "${SUPPORT_DAEMON}"
DSTATUS=$?
if [ "${DSTATUS}" = "1" ]; then
echo "${SUPPORT_DAEMON} is already running."
return
fi
if [ -x "${SUPPORT_DAEMON_WORKDIR}/${SUPPORT_DAEMON}" ]; then
echo -n "Starting ${SUPPORT_DAEMON} ... "
"${SUPPORT_DAEMON_WORKDIR}/${SUPPORT_DAEMON}" &
else
echo "Warning: support deamon ${SUPPORT_DAEMON_WORKDIR}/${SUPPORT_DAEMON} not found."
fi
}
status_support_daemon() {
SUPPORT_DAEMON=$1
if [ "${SUPPORT_DAEMON}" = "" ]; then
return 12
fi
if [ "${SUPPORT_DAEMON}" = "none" ]; then
return 13
fi
check_support_daemon "${SUPPORT_DAEMON}"
DSTATUS=$?
if [ "${DSTATUS}" = "0" ]; then
echo "${SUPPORT_DAEMON} is not running."
return;
fi
if [ "${DSTATUS}" = "1" ]; then
echo "${SUPPORT_DAEMON} is running."
return;
fi
echo "Error checking status of ${SUPPORT_DAEMON}"
}
# Source function library.
if [ -f /etc/rc.status ]; then
# SUSE
. /etc/rc.status
rc_reset
else
# Reset commands if not available
rc_status() {
case "$1" in
-v)
true
;;
*)
false
;;
esac
echo
}
alias rc_exit=exit
fi
if [ -x "$WORKDIR1" ]; then
WORKDIR="$WORKDIR1"
else
WORKDIR="$WORKDIR2"
fi
DAEMON=twonkystarter
TWONKYSRV="${WORKDIR}/${DAEMON}"
#cd $WORKDIR
# see if we need to start the twonky proxy service
PROXY_DAEMON=none
if [ "${START_PROXY}" = "1" ]; then
PROXY_DAEMON=twonkyproxy
fi
# see if we need to start the twonky tuner service
TUNER_DAEMON=none
if [ "${START_TUNER}" = "1" ]; then
TUNER_DAEMON=twonkytuner
fi
case "$1" in
start)
if [ -e $PIDFILE ]; then
PID=`cat $PIDFILE`
echo "Twonky server seems already be running under PID $PID"
echo "(PID file $PIDFILE already exists). Checking for process..."
running=`ps --no-headers -o "%c" -p $PID`
if ( [ "${DAEMON}" = "${running}" ] ); then
echo "Process IS running. Not started again."
else
echo "Looks like the daemon crashed: the PID does not match the daemon."
echo "Removing flag file..."
rm $PIDFILE
$0 start
exit $?
fi
exit 0
else
if [ ! -x "${TWONKYSRV}" ]; then
echo "Twonky server not found".
rc_status -u
exit $?
fi
start_support_daemon "${TUNER_DAEMON}" "${WORKDIR}"
echo -n "Starting $TWONKYSRV ... "
"$TWONKYSRV"
rc_status -v
fi
start_support_daemon "${PROXY_DAEMON}" "${WORKDIR}"
;;
stop)
if [ ! -e $PIDFILE ]; then
echo "PID file $PIDFILE not found, stopping server anyway..."
killall -s TERM ${DAEMON}
rc_status -u
stop_support_daemon "${PROXY_DAEMON}"
stop_support_daemon "${TUNER_DAEMON}"
exit 3
else
echo -n "Stopping Twonky MediaServer ... "
PID=`cat $PIDFILE`
kill -s TERM $PID
rm -f $PIDFILE
rc_status -v
stop_support_daemon "${PROXY_DAEMON}"
stop_support_daemon "${TUNER_DAEMON}"
fi
;;
reload)
if [ ! -e $PIDFILE ]; then
echo "PID file $PIDFILE not found, stopping server anyway..."
killall -s TERM ${DAEMON}
rc_status -u
exit 3
else
echo -n "Reloading Twonky server ... "
PID=`cat $PIDFILE`
kill -s HUP $PID
rc_status -v
fi
;;
restart)
$0 stop
$0 start
;;
status)
if [ ! -e $PIDFILE ]; then
running="`ps --no-headers -o pid -C ${DAEMON}`"
if [ "${running}" = "" ]; then
echo "No Twonky server is running"
else
echo "A Twonky server seems to be running with PID ${running}, but no PID file exists."
echo "Probably no write permission for ${PIDFILE}."
fi
status_support_daemon "${PROXY_DAEMON}"
status_support_daemon "${TUNER_DAEMON}"
exit 0
fi
PID=`cat $PIDFILE`
running=`ps --no-headers -o "%c" -p $PID`
if ( [ "${DAEMON}" = "${running}" ] ); then
echo "Twonky server IS running."
else
echo "Looks like the daemon crashed: the PID does not match the daemon."
fi
status_support_daemon "${PROXY_DAEMON}"
status_support_daemon "${TUNER_DAEMON}"
;;
*)
echo ""
echo "Twonky server"
echo "------------------"
echo "Syntax:"
echo " $0 {start|stop|restart|reload|status}"
echo ""
exit 3
;;
esac
rc_exit
|
Wenn ich das script in der Bash starte, dann funtioniert der start. Was ist den anders wenn systemd das script ausführt? 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 | matthias@naxos:~$ journalctl -xe | grep twonky
Aug 21 22:40:39 naxos twonky.sh[2427]: Starting /usr/local/twonky/twonkystarter ...
Aug 21 22:40:39 naxos systemd[1]: twonky.service: Main process exited, code=exited, status=13/n/a
Aug 21 22:40:41 naxos systemd[1]: twonky.service: Failed with result 'exit-code'.
Aug 21 22:41:12 naxos systemd[1]: twonky.service: Service hold-off time over, scheduling restart.
Aug 21 22:41:12 naxos systemd[1]: twonky.service: Scheduled restart job, restart counter is at 56.
-- Automatic restarting of the unit twonky.service has been scheduled, as the result for
Aug 21 22:41:12 naxos systemd[1]: Stopped twonky starter.
-- Subject: Unit twonky.service has finished shutting down
-- Unit twonky.service has finished shutting down.
Aug 21 22:41:12 naxos systemd[1]: Started twonky starter.
-- Subject: Unit twonky.service has finished start-up
-- Unit twonky.service has finished starting up.
Aug 21 22:41:12 naxos twonky.sh[2435]: Starting /usr/local/twonky/twonkystarter ...
Aug 21 22:41:12 naxos systemd[1]: twonky.service: Main process exited, code=exited, status=13/n/a
Aug 21 22:41:14 naxos systemd[1]: twonky.service: Failed with result 'exit-code'.
Aug 21 22:41:44 naxos systemd[1]: twonky.service: Service hold-off time over, scheduling restart.
Aug 21 22:41:44 naxos systemd[1]: twonky.service: Scheduled restart job, restart counter is at 57.
-- Automatic restarting of the unit twonky.service has been scheduled, as the result for
Aug 21 22:41:44 naxos systemd[1]: Stopped twonky starter.
-- Subject: Unit twonky.service has finished shutting down
-- Unit twonky.service has finished shutting down.
Aug 21 22:41:44 naxos systemd[1]: Started twonky starter.
-- Subject: Unit twonky.service has finished start-up
-- Unit twonky.service has finished starting up.
Aug 21 22:41:44 naxos twonky.sh[2441]: Starting /usr/local/twonky/twonkystarter ...
Aug 21 22:41:44 naxos systemd[1]: twonky.service: Main process exited, code=exited, status=13/n/a
Aug 21 22:41:46 naxos systemd[1]: twonky.service: Failed with result 'exit-code'.
|
Gruß Matthias
|
Kellerkind_2009
Anmeldungsdatum: 26. November 2009
Beiträge: 19617
Wohnort: Schleswig-Holstein
|
Ich glaube if [ "${SUPPORT_DAEMON}" = "none" ]; then
return 13 aber hier ist seahawk1986 der bessere Helfer 😉 Ziehe mich zurück.
|
seahawk1986
Anmeldungsdatum: 27. Oktober 2006
Beiträge: 11243
Wohnort: München
|
Da du den START_TUNER und START_PROXY nicht nutzt, kann man eigentlich alles in die Systemd-Unit packen und auf das Skript verzichten - probier es mal so:
[Unit]
Description=Twonky Server
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/local/twonky/twonkyserver \
-logfile /var/log/twonky.log
WorkingDirectory=/usr/local/twonky/
RestartSec=30
Restart=always
[Install]
WantedBy=multi-user.target
|
apt-ghetto
Anmeldungsdatum: 3. Juni 2014
Beiträge: 2943
|
Wenn ich das richtig verstanden habe, hast du den Dienst als normaler Nutzer gestartet? Dann solltest du im Abschnitt [Service] noch hinzufügen.
|
mw2000
(Themenstarter)
Anmeldungsdatum: 27. Dezember 2009
Beiträge: 90
|
HAllo zusammen, sorry für die späte Antwort aber ich war ein paar Tage nicht zuhause. Aktuelle Config: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 | [Unit]
Description=Twonky Server
Documentation=http://naxos/
After=network-online.target
[Service]
Type=simple
ExecStartPost=/usr/local/twonky/twonkyserver \
-logfile /var/log/twonky.log
WorkingDirectory=/usr/local/twonky
User=matthias
#TimeoutSec=0
#RemainAfterExit=no
RestartSec=30
Restart=always
[Install]
WantedBy=multi-user.target
|
Resultat: 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 | matthias@naxos:~$ sudo systemctl daemon-reload
matthias@naxos:~$ sudo systemctl status twonky.service
● twonky.service - Twonky Server
Loaded: error (Reason: Invalid argument)
Active: failed (Result: exit-code) since Tue 2018-08-21 22:48:43 CEST; 1 weeks 1 days ago
Docs: http://naxos/
Main PID: 2520 (code=exited, status=13)
Aug 22 06:34:49 naxos systemd[1]: twonky.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Aug 22 06:34:51 naxos systemd[1]: twonky.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Aug 23 06:05:57 naxos systemd[1]: twonky.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Aug 23 06:05:58 naxos systemd[1]: twonky.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Aug 23 06:05:59 naxos systemd[1]: twonky.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Aug 23 06:05:59 naxos systemd[1]: twonky.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Aug 29 23:51:17 naxos systemd[1]: twonky.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Aug 30 21:13:38 naxos systemd[1]: twonky.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Aug 30 21:14:56 naxos systemd[1]: twonky.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
Aug 30 21:17:26 naxos systemd[1]: twonky.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
|
keine Verbesserung.... ☹
|
lubux
Anmeldungsdatum: 21. November 2012
Beiträge: 14308
|
mw2000 schrieb: [Unit]
Description=Twonky Server
Documentation=http://naxos/
After=network-online.target
[Service]
Type=simple
ExecStartPost=/usr/local/twonky/twonkyserver \
-logfile /var/log/twonky.log
WorkingDirectory=/usr/local/twonky
User=matthias
#TimeoutSec=0
#RemainAfterExit=no
RestartSec=30
Restart=always
[Install]
WantedBy=multi-user.target
Warum hast Du "ExecStartPost" und nicht "ExecStart" verwendet? Lt. manpage:
If no ExecStart= is specified, then the service must have RemainAfterExit=yes and at least one ExecStop= line set.
|
mw2000
(Themenstarter)
Anmeldungsdatum: 27. Dezember 2009
Beiträge: 90
|
Hi lubux, weil ich das kopiert habe und TOMATEN auf den Augen 👍 1
2
3
4
5
6
7
8
9
10
11
12
13 | matthias@naxos:~$ sudo systemctl status twonky
● twonky.service - Twonky Server
Loaded: loaded (/etc/systemd/system/twonky.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2018-08-30 21:31:07 CEST; 1min 4s ago
Main PID: 19037 (twonkyserver)
Tasks: 13 (limit: 4436)
CGroup: /system.slice/twonky.service
└─19037 /usr/local/twonky/twonkyserver -logfile /var/log/twonky.log
Aug 30 21:31:07 naxos systemd[1]: twonky.service: Main process exited, code=exited, status=15/n/a
Aug 30 21:31:07 naxos systemd[1]: twonky.service: Failed with result 'exit-code'.
Aug 30 21:31:07 naxos systemd[1]: Stopped Twonky Server.
Aug 30 21:31:07 naxos systemd[1]: Started Twonky Server.
|
Schon funktioniert es... Danke an Alle Gruß Matthias
|