I have setup a Ubuntu Server with Plex installed. Plex is working great on it but I want to save some power so I want it to sleep when not in use. I installed powernap and it will put the server to sleep but not when I want it to.
I configured the TCPMonitor and told it if port 32400 was established then don't sleep. Well that works good if I don't use plex on the ROKU. It seems that once I close plex on Roku, Roku keeps the connection open. If I open plex from a web browser after it is closed the connection is then closed. When I run netstat -a --tcp on the server after plex is closed on Roku I get,
plex@PlexLinux:~$ netstat -a --tcp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 *:33443 *:* LISTEN
tcp 0 0 *:32400 *:* LISTEN
tcp 0 0 localhost:32401 *:* LISTEN
tcp 0 0 localhost:44566 *:* LISTEN
tcp 0 0 *:ssh *:* LISTEN
tcp 0 0 *:33400 *:* LISTEN
tcp 0 0 localhost:39417 *:* LISTEN
tcp 0 64 PlexLinux:ssh jeffHP-PC:65438 ESTABLISHED
tcp 0 0 PlexLinux:32400 NP-1GM354101541:55182 ESTABLISHED
tcp 0 0 PlexLinux:47730 J1:microsoft-ds ESTABLISHED
tcp 0 0 PlexLinux:35820 li394-5.members.l:https ESTABLISHED
tcp 0 0 PlexLinux:32400 NP-1GM354101541:55179 ESTABLISHED
tcp6 0 0 [::]:ftp [::]:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
As you can see port 32400 is still established but the Send-Q is 0. So is there a way to restart the plexmedia service if the Send-Q is 0 on all connections to port 32400? If I restart the service manual everything works as I want it to.
Or is there a better way to make the server sleep?