Page 1 of 1
Setting ports for service
Posted: Sunday 31 January 2021 1:54
by gpaolo79
Hi all,
I'm having a problem with the Domoticz server running on my ReadyNAS. It worked fine for a couple of months, then suddently it started to have a conflict with the apache server.
Apache is not running because it detects another service already listening on port 443, and that service is domoticz.
Code: Select all
root@xxxxxx:~# netstat -plan | grep domoticz
tcp6 0 0 :::8080 :::* LISTEN 4694/domoticz
tcp6 0 0 :::443 :::* LISTEN 4694/domoticz
tcp6 0 0 :::6144 :::* LISTEN 4694/domoticz
tcp6 0 0 192.168.1.100:8080 192.168.1.79:57577 ESTABLISHED 4694/domoticz
in the domoticz.service there is no mention of the ports:
Code: Select all
[Unit]
Description=Domoticz
After=network.target
[Service]
ExecStart=/opt/domoticz/domoticz -daemon
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
Inside the domoticz.sh in /etc/init.d I have changed the port to 4430
Code: Select all
DAEMON=/opt/domoticz/$NAME
DAEMON_ARGS="-daemon"
#DAEMON_ARGS="$DAEMON_ARGS -daemonname $NAME -pidfile $PIDFILE"
DAEMON_ARGS="$DAEMON_ARGS -www 8080"
DAEMON_ARGS="$DAEMON_ARGS -sslwww 4430"
DAEMON_ARGS="$DAEMON_ARGS -log /tmp/domoticz.txt"
DAEMON_ARGS="$DAEMON_ARGS -syslog"
but it looks like it is completely ignored.
I don't know what else to try, could please someone give me some indication?
Thanks!
Re: Setting ports for service
Posted: Sunday 31 January 2021 1:56
by gpaolo79
Sorry, I forgot an important bit of information. I'm running Domoticz V4.10717 becuase it's the last version that can run on my NAS.
Re: Setting ports for service
Posted: Sunday 31 January 2021 11:18
by waaren
gpaolo79 wrote: ↑Sunday 31 January 2021 1:54
...but it looks like it is completely ignored.
I don't know what else to try, could please someone give me some indication?
Have a look in
/var/packages/domoticz/scripts/start-stop-status
Re: Setting ports for service
Posted: Sunday 31 January 2021 12:14
by gpaolo79
waaren wrote: ↑Sunday 31 January 2021 11:18
Have a look in
/var/packages/domoticz/scripts/start-stop-status
I don't have that directory.
Domoticz was installed using the command tar -zxf /tmp/domoticz_linux_x86_64.tgz inside opt/domoticz/ ---these were the only instructions I could find to install it on my type of NAS.
There must be a copy of the launch script somewhere.
Yesterday night I have tried to launch the deamon manually with the same configuration in the domoticz.sh script and it works fine, with the right ports, but linux is not calling that script at all. I have even tried to delete it and the command service start domoticz still works with no error, except for the fact that it ignores the configuration.
Any chance that I need to use the update-rc.d to remove the service and reload it? I have tried but I might have missed something, because even after a update-rc.d domoticz.sh remove, I can still launch it with the service domoticz.sh start command...
Re: Setting ports for service
Posted: Sunday 31 January 2021 12:31
by erem
do you have a domoticz.sh in /etc/init.d?
if so try and change that, then just reboot your nas. overkill, i know, but safe.
Re: Setting ports for service
Posted: Sunday 31 January 2021 12:32
by gpaolo79
erem wrote: ↑Sunday 31 January 2021 12:31
do you have a domoticz.sh in /etc/init.d?
if so try and change that, then just reboot your nas. overkill, i know, but safe.
I do have it, yes.
I have tried to start and stop it many times but not rebooting the NAS. I'll try that one and I'll let you know, thanks.
Re: Setting ports for service
Posted: Sunday 31 January 2021 12:43
by gpaolo79
Nope. Reboot didn't change it. I still have:
Code: Select all
root@NAS4-CASA-GP:~# netstat -plan | grep domotic
tcp6 0 0 :::6144 :::* LISTEN 4677/domoticz
tcp6 0 0 :::8080 :::* LISTEN 4677/domoticz
tcp6 0 0 :::443 :::* LISTEN 4677/domoticz
while the configuration in /etc/init.d/domoticz.sh is
Code: Select all
DAEMON=/opt/domoticz/$NAME
DAEMON_ARGS="-daemon"
#DAEMON_ARGS="$DAEMON_ARGS -daemonname $NAME -pidfile $PIDFILE"
DAEMON_ARGS="$DAEMON_ARGS -www 8080"
DAEMON_ARGS="$DAEMON_ARGS -sslwww 0"
DAEMON_ARGS="$DAEMON_ARGS -log /tmp/domoticz.txt"
DAEMON_ARGS="$DAEMON_ARGS -syslog"
If I kill the service, start apache and start the service it works fine, because domoticz finds the port already used by apache and ignores it.
Code: Select all
root@NAS4-CASA-GP:~# kill 4677
root@NAS4-CASA-GP:~# systemctl start apache2
root@NAS4-CASA-GP:~# service domoticz start
root@NAS4-CASA-GP:~# netstat -plan | grep domotic
tcp6 0 0 :::6144 :::* LISTEN 8461/domoticz
tcp6 0 0 :::8080 :::* LISTEN 8461/domoticz
unix 2 [ ] DGRAM 26751 8461/domoticz
It might be worth to mention that stopping the service doesn't do anything, but I don't get any error either:
Code: Select all
root@NAS4-CASA-GP:/etc/init.d# netstat -plan | grep domotic
tcp6 0 0 :::6144 :::* LISTEN 8461/domoticz
tcp6 0 0 :::8080 :::* LISTEN 8461/domoticz
unix 2 [ ] DGRAM 26751 8461/domoticz
root@NAS4-CASA-GP:/etc/init.d# service domoticz stop
root@NAS4-CASA-GP:/etc/init.d# netstat -plan | grep domotic
tcp6 0 0 :::6144 :::* LISTEN 8461/domoticz
tcp6 0 0 :::8080 :::* LISTEN 8461/domoticz
unix 2 [ ] DGRAM 26751 8461/domoticz
Re: Setting ports for service
Posted: Sunday 31 January 2021 12:55
by erem
i am not ure if DAEMON_ARGS="$DAEMON_ARGS -sslwww 0" is a valid domoticz config
try and change that to 4330 again, and reboot again
it is also very strange that the service stop does not work.
i am not sure how to interpret that, but it certainly requires further investigation.
what does
show before and after the stop
your domoticz.service also looks suspicious. it does not look like it is generated by systemd from domoticz.sh.
could yu be starting domoticz thru systemd instead of sysv.
try
Code: Select all
sudo systemctl stop domoticz.service
as well with the ps command
Re: Setting ports for service
Posted: Sunday 31 January 2021 13:18
by gpaolo79
erem wrote: ↑Sunday 31 January 2021 12:55
i am not ure if DAEMON_ARGS="$DAEMON_ARGS -sslwww 0" is a valid domoticz config
try and change that to 4330 again, and reboot again
it is also very strange that the service stop does not work.
i am not sure how to interpret that, but it certainly requires further investigation.
what does
show before and after the stop
So, changed to 4330 and reboot, no luck. Still stuck on defaults:
Code: Select all
root@NAS4-CASA-GP:~# netstat -plan | grep domotic
tcp6 0 0 :::443 :::* LISTEN 4678/domoticz
tcp6 0 0 :::6144 :::* LISTEN 4678/domoticz
tcp6 0 0 :::8080 :::* LISTEN 4678/domoticz
and apache is not running.
This is the command you have indicated before and after stop:
Code: Select all
root@NAS4-CASA-GP:~# ps -aux | grep domoticz
root 4678 0.7 0.9 967328 36196 ? Ssl 12:12 0:00 /opt/domoticz/domoticz -daemon
root 7976 0.0 0.0 17840 1048 pts/0 S+ 12:14 0:00 grep domoticz
root@NAS4-CASA-GP:~# service domoticz stop
root@NAS4-CASA-GP:~# ps -aux | grep domoticz
root 4678 0.6 0.9 967328 36196 ? Ssl 12:12 0:00 /opt/domoticz/domoticz -daemon
root 7998 0.0 0.0 17840 1048 pts/0 S+ 12:14 0:00 grep domoticz
Note that if I kill it and start it manually it works fine:
Code: Select all
root@NAS4-CASA-GP:~# netstat -plan | grep domotic
tcp6 0 0 :::443 :::* LISTEN 4678/domoticz
tcp6 0 0 :::6144 :::* LISTEN 4678/domoticz
tcp6 0 0 :::8080 :::* LISTEN 4678/domoticz
unix 2 [ ] DGRAM 9750 4678/domoticz
root@NAS4-CASA-GP:~# kill 4678
root@NAS4-CASA-GP:~# start-stop-daemon --start --pidfile /var/run/domoticz.pid --exec /opt/domoticz/domoticz -- -daemon -www 8080 -sslwww 4430
2021-01-31 12:15:31.891 Status: Domoticz V4.10717 (c)2012-2019 GizMoCuz
2021-01-31 12:15:31.891 Status: Build Hash: b38b49e5, Date: 2019-05-09 11:04:08
2021-01-31 12:15:31.891 Status: Startup Path: /opt/domoticz/
domoticz: Domoticz is starting up....
root@NAS4-CASA-GP:~# netstat -plan | grep domotic
tcp6 0 0 :::6144 :::* LISTEN 8208/domoticz
tcp6 0 0 :::4430 :::* LISTEN 8208/domoticz
tcp6 0 0 :::8080 :::* LISTEN 8208/domoticz
unix 2 [ ] DGRAM 25447 8208/domoticz
so it's just that, somehow, the domoticz.sh file is ignored.
Also, if I launch the stop command manually, the service is actually stopped correctly.
I think the key is to understand where is it getting the script from. For sure not from /etc/init.d, because if I remove it, it keeps starting as if nothing had happened.
Re: Setting ports for service
Posted: Sunday 31 January 2021 13:19
by gpaolo79
I was thinking, as workaround if it's not possible to understand why the .sh is ignored, is there any way to configure the service for a delayed start, so it starts *after* apache?
Re: Setting ports for service
Posted: Sunday 31 January 2021 13:23
by gpaolo79
erem wrote: ↑Sunday 31 January 2021 12:55
your domoticz.service also looks suspicious. it does not look like it is generated by systemd from domoticz.sh.
could yu be starting domoticz thru systemd instead of sysv.
try
Code: Select all
sudo systemctl stop domoticz.service
as well with the ps command
sorry, I missed this bit.
That doesn't work either:
Code: Select all
root@NAS4-CASA-GP:~# systemctl stop domoticz.service
root@NAS4-CASA-GP:~# netstat -plan | grep domotic
tcp6 0 0 :::6144 :::* LISTEN 8208/domoticz
tcp6 0 0 :::4430 :::* LISTEN 8208/domoticz
tcp6 0 0 :::8080 :::* LISTEN 8208/domoticz
unix 2 [ ] DGRAM 25447 8208/domoticz
root@NAS4-CASA-GP:~# ps -aux | grep domoticz
root 8208 0.3 0.9 1032864 36216 ? Ssl 12:15 0:01 /opt/domoticz/domoticz -daemon -www 8080 -sslwww 4430
root 8734 0.0 0.0 17836 944 pts/0 S+ 12:20 0:00 grep domoticz
ah but this is interesting. Now the service is indicated launched with the settings, while before it wasn't.
Code: Select all
root 4678 0.6 0.9 967328 36196 ? Ssl 12:12 0:00 /opt/domoticz/domoticz -daemon
root 8208 0.3 0.9 1032864 36216 ? Ssl 12:15 0:01 /opt/domoticz/domoticz -daemon -www 8080 -sslwww 4430
What could be the cause of this?
Re: Setting ports for service
Posted: Sunday 31 January 2021 13:27
by erem
this leads me to believe your domoticz is started from systemd.
can you try and change the domoticz.service to
Code: Select all
ExecStart=/opt/domoticz/domoticz -daemon -www 8080 -sslwww 4430
and then reboot again
Re: Setting ports for service
Posted: Sunday 31 January 2021 13:32
by gpaolo79
erem wrote: ↑Sunday 31 January 2021 13:27
this leads me to believe your domoticz is started from systemd.
can you try and change the domoticz.service to
Code: Select all
ExecStart=/opt/domoticz/domoticz -daemon -www 8080 -sslwww 4430
and then reboot again
Ok I have tried to make the change, this is now the domoticz.service:
Code: Select all
[Unit]
Description=Domoticz
After=network.target
[Service]
ExecStart=/opt/domoticz/domoticz -daemon -www 8080 -sslwww 4430
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
It does notice that the service has changed, but stopping and restarting it still doesn't work. I'll try rebooting now...
Code: Select all
root@NAS4-CASA-GP:/lib/systemd/system# netstat -plan | grep domotic
tcp6 0 0 :::6144 :::* LISTEN 8208/domoticz
tcp6 0 0 :::4430 :::* LISTEN 8208/domoticz
tcp6 0 0 :::8080 :::* LISTEN 8208/domoticz
unix 2 [ ] DGRAM 25447 8208/domoticz
root@NAS4-CASA-GP:/lib/systemd/system# kill 8208
root@NAS4-CASA-GP:/lib/systemd/system# netstat -plan | grep domotic
unix 2 [ ] DGRAM 25447 8208/domoticz
root@NAS4-CASA-GP:/lib/systemd/system# systemctl start domoticz.service
Warning: domoticz.service changed on disk. Run 'systemctl daemon-reload' to reload units.
root@NAS4-CASA-GP:/lib/systemd/system# systemctl daemon-reload
root@NAS4-CASA-GP:/lib/systemd/system# systemctl start domoticz.service
root@NAS4-CASA-GP:/lib/systemd/system# ps -aux | grep domoticz
root 9069 0.8 0.9 819864 36680 ? Ssl 12:29 0:00 /opt/domoticz/domoticz -daemon
root 9106 0.0 0.0 17836 1032 pts/0 S+ 12:29 0:00 grep domoticz
root@NAS4-CASA-GP:/lib/systemd/system# netstat -plan | grep domotic
tcp6 0 0 :::6144 :::* LISTEN 9069/domoticz
tcp6 0 0 :::8080 :::* LISTEN 9069/domoticz
unix 2 [ ] DGRAM 40521 9069/domoticz
Re: Setting ports for service
Posted: Sunday 31 January 2021 13:36
by gpaolo79
ah! rebooting did the trick!
Now it got the right ports:
Code: Select all
root@NAS4-CASA-GP:~# netstat -plan | grep domotic
tcp6 0 0 :::8080 :::* LISTEN 4737/domoticz
tcp6 0 0 :::6144 :::* LISTEN 4737/domoticz
tcp6 0 0 :::4430 :::* LISTEN 4737/domoticz
unix 2 [ ] DGRAM 10354 4737/domoticz
Thank you SO MUCH! I would have never made it without your help. I'm not exactly a linux expert
Re: Setting ports for service
Posted: Sunday 31 January 2021 13:47
by erem
well, that is confirming that the systemd service file starts domoticz.
either you update the file with all required startup options like logfile etc, or you rename the file to domoticz.sevice.save.
if you then reboot again, systemd should recognize there is no service file for domoticz, and generate one from domoticz.sh in directory /run/systemd/generator.late/
anyway, since you are running systemd, use systemctl to manage services.
good luck,
Re: Setting ports for service
Posted: Sunday 31 January 2021 20:22
by waaren
erem wrote: ↑Sunday 31 January 2021 12:55
I am not sure if DAEMON_ARGS="$DAEMON_ARGS -sslwww 0" is a valid domoticz config
Yes it is. It disables https access.
Re: Setting ports for service
Posted: Wednesday 03 February 2021 10:49
by gpaolo79
Hello again,
an update. Today I have noticed that the web page was not loading, so I checked with the ssh and the service was indicated as running, although there was no domoticz process alive.
So I have restarted the service with the systemctl command and the web interface restarted.
But I have noticed that the temperatures were not updating, the last time was yesterday morning, and even after a few minutes it showed no sign to get any new data.
Out of curiosity, I tried to launch the service also with the service domoticz start command, and immediately the values got updated and everything is running fine again.
Do you have any idea of why this could be happening? I have the feeling that there is something quite messed up with my configuration...
Re: Setting ports for service
Posted: Wednesday 03 February 2021 11:30
by waaren
gpaolo79 wrote: ↑Wednesday 03 February 2021 10:49
Do you have any idea of why this could be happening? I have the feeling that there is something quite messed up with my configuration...
Would be interesting to see the first 100 lines or so of the domoticz log for both types of starts