Webmin

When I make any changes on webmin it doesn’t restart webmin I have to restart the pi. I have reinstalled and still the same. Any ideas?

Why should Webmin restart? You can do that from console via systemctl restart webmin or does it have an internal service restart option that does not work?

It says connection has been lost and doesn’t reconnect

You mean when you use the internal restart button? Waiting a bit longer and hitting F5 in the browser to reload the site doesn’t help?

If so, please paste the output of the following console command:

journalctl -u webmin

Make any settings change and click apply webmin should restart but it doesn’t

journalctl -u webmin
-- Logs begin at Sat 2021-03-20 16:05:21 GMT, end at Sat 2021-03-20 16:18:04 GMT. --
Mar 20 16:05:52 Burgess-Server systemd[1]: Starting Webmin (DietPi)...
Mar 20 16:05:52 Burgess-Server start[881]: Starting Webmin server in /usr/share/webmin
Mar 20 16:05:53 Burgess-Server perl[881]: pam_unix(webmin:auth): a
uthentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=root
Mar 20 16:05:55 Burgess-Server webmin[881]: Webmin starting
Mar 20 16:05:56 Burgess-Server systemd[1]: Started Webmin (DietPi).
Mar 20 16:16:16 Burgess-Server perl[912]: pam_unix(webmin:auth): a
uthentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=root
Mar 20 16:16:17 Burgess-Server webmin[912]: Webmin starting
Mar 20 16:16:18 Burgess-Server stop[1628]: Stopping Webmin server in /usr/share/webmin
Mar 20 16:16:18 Burgess-Server systemd[1]: webmin.service: Succeeded.

Indeed it stops. Hmm if the restart feature stops the main process and service type is simple (default) this actually makes sense as systemd sees the main process stopping and kills all related children automatically. Looks like a bug in Webmin to me, related on either a change in its systemd unit or its restart handler. In case should be reported here: https://github.com/webmin/webmin/issues
But I’m not able to replicate until next week.

Just for completeness, issue was reported by OT towards webmin https://github.com/webmin/webmin/issues/1463

BTW: I can replicate the behaviour. It seems the way how systemd service is working. If I call webmin directly (without systemd) using /etc/webmin/start, Webmin is going to be restarted correctly from GUI.

And now I have 2 instance running. First one is parent of 2nd one

root@DietPi3:~# ps -ef |grep web
root      4388     1  0 23:07 ?        00:00:00 /usr/bin/perl /usr/share/webmin/miniserv.pl /etc/webmin/miniserv.conf
root      4421  4388  0 23:07 ?        00:00:00 /usr/bin/perl /usr/share/webmin/miniserv.pl /etc/webmin/miniserv.conf

But it’s not the case all the time. Strange behaviour

And I forgot that we create that systemd unit. So a bug our side we need to fix. I’ll have a look into this. A wrapper shell would be an easy solution but cause an additional process :thinking:.

what about restart feature inside systemd??

It’s not perfect but working

[Unit]
Description=Webmin (DietPi)

StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
Restart=always
RestartSec=5s
Type=forking
ExecStart=/etc/webmin/start
ExecStop=/etc/webmin/stop

[Install]
WantedBy=multi-user.target



root@DietPi3:~# journalctl -u webmin.service -f
-- Logs begin at Thu 2019-02-14 11:11:58 CET. --
Mar 20 23:42:15 DietPi3 systemd[1]: Starting Webmin (DietPi)...
Mar 20 23:42:15 DietPi3 start[429]: Starting Webmin server in /usr/share/webmin
Mar 20 23:42:16 DietPi3 perl[429]: pam_unix(webmin:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=root
Mar 20 23:42:18 DietPi3 webmin[429]: Webmin starting
Mar 20 23:42:20 DietPi3 systemd[1]: Started Webmin (DietPi).
Mar 20 23:44:00 DietPi3 perl[664]: pam_unix(webmin:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=root
Mar 20 23:44:02 DietPi3 webmin[664]: Webmin starting
Mar 20 23:44:03 DietPi3 stop[1225]: Stopping Webmin server in /usr/share/webmin
Mar 20 23:44:03 DietPi3 systemd[1]: webmin.service: Succeeded.
Mar 20 23:44:08 DietPi3 systemd[1]: webmin.service: Service RestartSec=5s expired, scheduling restart.
Mar 20 23:44:08 DietPi3 systemd[1]: webmin.service: Scheduled restart job, restart counter is at 1.
Mar 20 23:44:08 DietPi3 systemd[1]: Stopped Webmin (DietPi).
Mar 20 23:44:08 DietPi3 systemd[1]: Starting Webmin (DietPi)...
Mar 20 23:44:08 DietPi3 start[1231]: Starting Webmin server in /usr/share/webmin
Mar 20 23:44:08 DietPi3 perl[1231]: pam_unix(webmin:auth): authentication failure; logname= uid=0 euid=0 tty= ruser= rhost=  user=root
Mar 20 23:44:10 DietPi3 webmin[1231]: Webmin starting
Mar 20 23:44:11 DietPi3 systemd[1]: Started Webmin (DietPi).

Unfortunately Restart=always would need to be used as on-failure doesn’t seems to be working

For the systemd restart feature we’d need to find the exit code or signal when an internal restart is done. This can then be used to trigger a systemd restart conditionally. Otherwise we’d either prevent an intended stop or have a restart loop on failure. With a wrapper script it’s actually the same, but we have more tools like checking for the process that performs the restart. I’ll run some tests next week.

well adding StartLimitBurst should prevent uncontrolled restart loops and stop the service after a specified attempts, isn’t it?

Jep exactly. It’s still not perfect as in cases when users change settings often, frequent restarts may be expected while hitting the limit. But until we find a better solution via exit code or signal, it’s an option.

Do I need to change anything?

Well you could try to adjust your webmin service file as follow. It would be a workaround until a final solution was found

[Unit]
Description=Webmin (DietPi)

StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
Restart=always
RestartSec=5s
Type=forking
ExecStart=/etc/webmin/start
ExecStop=/etc/webmin/stop

[Install]
WantedBy=multi-user.target

Did you have an update please?

as stated above, you can adjust your service file as workaround.

Sorry where do I find it?

you can do it on a drop-in config for webmin service

nano /etc/systemd/system/webmin.service.d/dietpi-services_edit.conf

and add

[Unit]
StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
Restart=always
RestartSec=5s

once done

systemctl daemon-reload
systemctl restart webmin.service

Alternative solution has now been implemented for DietPi v7.2: https://github.com/MichaIng/DietPi/pull/4331
Quick test of the approach would be:

sed -i '/\[Service\]/a\GuessMainPID=no' /etc/systemd/system/webmin.service
systemctl daemon-reload
systemctl restart webmin