Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 03-02-2019, 13:33   #1
Registered User

Join Date: Feb 2019
Posts: 8
kplex start vs restart

Hi,


I tried to restart kplex. For my understanding kplex should stop and after sleep 2 kplex should start. As I saw with pgrep kplex, kplex disappeared and after 2 seconds it was not loaded.

After the second restart, kplex was loaded.



Hope anybody can explain
Juergen
__________________

landi is offline   Reply With Quote
Old 03-02-2019, 14:55   #2
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,757
Re: kplex start vs restart

The second restart simply was the same as a start. Without looking at least at your logs I would evaluate the chance you could get an explanation as next to non existent.

Pavel
__________________

nohal is offline   Reply With Quote
Old 03-02-2019, 15:01   #3
Registered User

Join Date: Feb 2019
Posts: 8
Re: kplex start vs restart

Hi pavel,
which logs do you mean?
Juergen
landi is offline   Reply With Quote
Old 03-02-2019, 15:04   #4
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,757
Re: kplex start vs restart

Main syslog (= usually /var/log/syslog or /var/log/messages), systemd if applicable, the ones produced by kplex itself if any.

If you ask me, I would simply ignore this "incident" if it was not 100% reproducible....
nohal is offline   Reply With Quote
Old 03-02-2019, 15:12   #5
Registered User

Join Date: Feb 2019
Posts: 8
Re: kplex start vs restart

Click image for larger version

Name:	kplex01.jpg
Views:	52
Size:	53.6 KB
ID:	185151

Click image for larger version

Name:	kplex02.jpg
Views:	45
Size:	6.7 KB
ID:	185152
landi is offline   Reply With Quote
Old 03-02-2019, 15:15   #6
Registered User

Join Date: Feb 2019
Posts: 8
Re: kplex start vs restart

Click image for larger version

Name:	kplex03.jpg
Views:	48
Size:	45.4 KB
ID:	185153
landi is offline   Reply With Quote
Old 03-02-2019, 15:24   #7
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,757
Re: kplex start vs restart

You will have to dig deeper, but at least we know that you are probably using raspbian and systemd...

From what I see kplex is using the old sys-v style init scripts instead of a real systemd unit, which is an idea worse with every systemd release, so I would probably read the /etc/init.d/kplex script and reimplemented it as a systemd unit instead (Which as a bonus will also give you automatic restarts in case the thing crashes).
nohal is offline   Reply With Quote
Old 03-02-2019, 15:33   #8
Registered User

Join Date: Feb 2019
Posts: 8
Re: kplex start vs restart

Thanks.
How can I convert and embed the script as system unit?
landi is offline   Reply With Quote
Old 03-02-2019, 15:47   #9
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,757
Re: kplex start vs restart

1. You read what it does. I have never seen kplex, but from a very short look at it's source would suspect that actually nothing but "/usr/bin/kplex -f /etc/kplex.conf"
2. You write a service unit to do the same, in this case probably something like (remember that I really do not know kplex besides the fact it exists)
Code:
[Unit]
Description=kplex multiplexer

[Service]
ExecStart=/usr/bin/kplex -f /etc/kplex.conf
Restart=always 

[Install]
WantedBy=multi-user.target
and save it as /etc/systemd/system/kplex.service (I would probably also stop kplex before doing this)
3. You get rid of the /etc/init.d/kplex script
4. You start the service
Code:
systemctl start kplex.service
5. You make it start automatically
Code:
systemctl enable kplex.service
6. You contribute the working systemd unit upstream

Relevant systemd documentation: https://www.freedesktop.org/software...d.service.html
nohal is offline   Reply With Quote
Old 03-02-2019, 16:00   #10
Registered User

Join Date: Feb 2019
Posts: 8
Re: kplex start vs restart

Thanks.
I will try, but this will take several days....
I will report.
landi is offline   Reply With Quote
Old 04-02-2019, 00:07   #11
Registered User

Join Date: Feb 2019
Posts: 8
Re: kplex start vs restart

Hi,
here are the first results.
The kplex.service was aready installed. I made a new service kplex_jl, but it didnt work. Where ist the mistake?


Click image for larger version

Name:	service08.jpg
Views:	36
Size:	30.7 KB
ID:	185167

Click image for larger version

Name:	service07.jpg
Views:	38
Size:	21.1 KB
ID:	185168

Click image for larger version

Name:	service06.jpg
Views:	39
Size:	200.6 KB
ID:	185169
landi is offline   Reply With Quote
Old 04-02-2019, 04:33   #12
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,757
Re: kplex start vs restart

The mistake in one of them sure is you use the forking mode and start kplex with -o background. Do not do this. The second mistake in the same one is you do not specify the configfile location using the -f parameter (if your configfile is in one of the default locations not needed)

The mistake in the second one is wrong value for the -f parameter, /var/run/kplex.pid is not your config file, I would say.
nohal is offline   Reply With Quote
Old 04-02-2019, 05:37   #13
Registered User

Join Date: Feb 2019
Posts: 8
Re: kplex start vs restart

Quote:
Originally Posted by nohal View Post
The mistake in one of them sure is you use the forking mode and start kplex with -o background. Do not do this.

The second mistake in the same one is you do not specify the configfile location using the -f parameter (if your configfile is in one of the default locations not needed)
Okay, but this ist the original after installation.



Quote:
Originally Posted by nohal View Post
The mistake in the second one is wrong value for the -f parameter, /var/run/kplex.pid is not your config file, I would say.

Yes, now I see.
I will try it in the evening.
Thanks
landi is offline   Reply With Quote
Old 04-02-2019, 05:46   #14
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,757
Re: kplex start vs restart

Quote:
Originally Posted by landi View Post
Okay, but the service it is the original after installation.
I do not understand what you are trying to say, but you can't simply copy everything you see.
Systemd is much more powerful than the old init system in terms of service management so it is generally not a good idea fighting with it.
The forking type is there only to support stuff where you don't have a choice and for special cases where you would need to wait for something that needs to happen before the PID file is created. Neither is the case with kplex as far as I can tell.
nohal is offline   Reply With Quote
Old 07-02-2019, 14:03   #15
Registered User

Join Date: Oct 2012
Location: Brighton, UK
Boat: Westerly Oceanlord
Posts: 388
Re: kplex start vs restart

Quote:
Originally Posted by nohal View Post
From what I see kplex is using the old sys-v style init scripts instead of a real systemd unit, which is an idea worse with every systemd release, so I would probably read the /etc/init.d/kplex script and reimplemented it as a systemd unit instead (Which as a bonus will also give you automatic restarts in case the thing crashes).
Yes and no..

Yes for systemd-based systems unit files are a much better idea. But init scripts do still work (as long as they don't have possible errors in (see below))

The release announcement for the most recent kplex version noted the systemd issue and the fact that a unit file is now distributed with kplex but not enabled. Why? Well, basically incompetence and impatience but there were mitigating factors that I'll explain elsewhere rather than clutter up the OpenCPN forum. Suffice to say: The provided unit file should work for those who prefer to use it.

Quote:
Originally Posted by nohal View Post
The mistake in one of them sure is you use the forking mode and start kplex with -o background.
You were right about the second mistake. I don't guarantee it but the first might not be a mistake (and if it is, it came from my unit file, so my bad). kplex does do its set-up before forking and writes the child (background) pid to the pidfile.

I've replied to landi on the kplex forum where this issue was also posted but if I were to place a bet it would be on the surprised-no-one-reported-that-til-now error in the init script which leaves 2 seconds between shutdown and startup when kplex's grace period for shutting down connections (ie time from receipt of SIGTERM kplex allows to cleanly shut down interface before killing all threads and exiting) is 3 seconds, so if you have a problematic connection that won't die cleanly, this might well exhibit this behaviour. debuglevel=3 in the [global] section of the config file would help with knowing what was going on. Using the unit file, hacking the init script to make the restart delay 4 seconds, or adding graceperiod=1 to [global] might all address the restart/grace period mis-match if that is indeed what lands is facing.
__________________

muttnik is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenCPN - OpenPlotter - KPlex - RPi - CPU Maxed Out Dsanduril OpenCPN 8 26-09-2018 11:44
kplex on Raspberry Pi --howto bzs OpenCPN 5 20-02-2017 13:32
Ubuntu Version gpsd Restart Daemon ? sdowney717 OpenCPN 0 08-08-2011 09:24



Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -7. The time now is 03:56.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2019, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.