Hallo,
ich habe vor kurzem ein Synology NAS gekauft (DS218+). Darauf habe ich einen seafile docker container am laufen, mich aber darüber geärgert das dieser verhindert das die Festplatten herunterfahren können. Daher habe ich eine Lösung dafür gesucht und gebaut die ich hier gerne weitergeben möchte da sind nicht auf seafile begrenzt ist sondern für alle möglichen Dienste verwendet werden kann welche den Festplatten Schlafmodus verhindern aber trotzdem nutzbar sein sollen.
Hintergund ist das der Dienst (in diesem Fall seafile als docker container) nur bei Bedarf gestartet wird, automatisch bei Netzwerk Zugriff und ohne das eine Anfrage ins Leere läuft. Nach 10 min ohne netzwerkzugriff wird der Dienst wieder gestoppt und die Festplatten können wieder in den Ruhezustand gehen.
Ich hatte die Anleitung gleich in englisch geschrieben, aber das Englische Synology Forum https://community.synology.com/forum/ ist irgendwie seltsam...
Daher hier erstmal alles in englisch. Gibt es hier im Forum einen Howto Bereich? habe nichts derartiges gefunden.
Startup a docker container or application to run on demand (on network access)
On my Synology DS218+ i am running a seafile docker container. It runs fine so far, but as long as seafile is running the harddisks never spin down.
Since i do not need seafile all the time this a waste of energy and the hard disks do run unnecessarily long, which is not good for its lifetime.
I searched for a solution and found something that is maybe usefull for other applications that prevent spindown of harddisks, too.
It is based on the idea that the service only should startup when someone uses it.
After some research i found the systemd-socket-proxyd would be useful for this. It listens on a port and do something when traffic to this port comes in.
So when someone accesses the port it can start for example an application or in my case a docker container.
When the application or conainer is up and ready to serve the request it will forward it without interrupt.
This way i can have my seafile container turned off and it will only be started when accessed, the application will not get a not available message, it will just wait for some seconds until the application is up.
When seafile has not been used for 10 mintues it will shutdown its container so the harddiks may spin down again.
An example how it works:
Client -> https://mydomain.com (Port 443, <IP of SynologyNAS>)
Request to seafile website
-> 443:<IP of SynologyNAS> (SynologyNAS reverse proxy application)
The reverse Proxy of Synology redirects the traffic to the CentOS docker container
-> 81:<IP of SynologyNAS> (CentOS docker container)
The CentOS cocker container listens on this port, it will start the seafile container and redirect the traffic there
It will monitor open connections to the port, after 10 minutes without open connections it will shutdown the docker container.
This will be done by logging with ssh from docker container to Synology NAS IP and executing the appropriate command.
-> 82:<IP of SynologyNAS> (seafile docker container)
The seafile docker container listens on this port (internally port 80) will answer the request
ich habe vor kurzem ein Synology NAS gekauft (DS218+). Darauf habe ich einen seafile docker container am laufen, mich aber darüber geärgert das dieser verhindert das die Festplatten herunterfahren können. Daher habe ich eine Lösung dafür gesucht und gebaut die ich hier gerne weitergeben möchte da sind nicht auf seafile begrenzt ist sondern für alle möglichen Dienste verwendet werden kann welche den Festplatten Schlafmodus verhindern aber trotzdem nutzbar sein sollen.
Hintergund ist das der Dienst (in diesem Fall seafile als docker container) nur bei Bedarf gestartet wird, automatisch bei Netzwerk Zugriff und ohne das eine Anfrage ins Leere läuft. Nach 10 min ohne netzwerkzugriff wird der Dienst wieder gestoppt und die Festplatten können wieder in den Ruhezustand gehen.
Ich hatte die Anleitung gleich in englisch geschrieben, aber das Englische Synology Forum https://community.synology.com/forum/ ist irgendwie seltsam...
Daher hier erstmal alles in englisch. Gibt es hier im Forum einen Howto Bereich? habe nichts derartiges gefunden.
Startup a docker container or application to run on demand (on network access)
On my Synology DS218+ i am running a seafile docker container. It runs fine so far, but as long as seafile is running the harddisks never spin down.
Since i do not need seafile all the time this a waste of energy and the hard disks do run unnecessarily long, which is not good for its lifetime.
I searched for a solution and found something that is maybe usefull for other applications that prevent spindown of harddisks, too.
It is based on the idea that the service only should startup when someone uses it.
After some research i found the systemd-socket-proxyd would be useful for this. It listens on a port and do something when traffic to this port comes in.
So when someone accesses the port it can start for example an application or in my case a docker container.
When the application or conainer is up and ready to serve the request it will forward it without interrupt.
This way i can have my seafile container turned off and it will only be started when accessed, the application will not get a not available message, it will just wait for some seconds until the application is up.
When seafile has not been used for 10 mintues it will shutdown its container so the harddiks may spin down again.
An example how it works:
Client -> https://mydomain.com (Port 443, <IP of SynologyNAS>)
Request to seafile website
-> 443:<IP of SynologyNAS> (SynologyNAS reverse proxy application)
The reverse Proxy of Synology redirects the traffic to the CentOS docker container
-> 81:<IP of SynologyNAS> (CentOS docker container)
The CentOS cocker container listens on this port, it will start the seafile container and redirect the traffic there
It will monitor open connections to the port, after 10 minutes without open connections it will shutdown the docker container.
This will be done by logging with ssh from docker container to Synology NAS IP and executing the appropriate command.
-> 82:<IP of SynologyNAS> (seafile docker container)
The seafile docker container listens on this port (internally port 80) will answer the request