ryran / reboot-guard

Block systemd-initiated poweroff/reboot/halt until configurable condition checks pass
GNU General Public License v3.0
51 stars 5 forks source link

feedback-stories tvheadend #7

Open prietus opened 7 years ago

prietus commented 7 years ago

I used to have tvheadend running in a odroid c1. lately I needed to do transcoding and the odroid c1 is too weak so I set it up in a proper machine. I do care about power consumption so I needed to figure out a way of having the machine hibernated while not watching the iptv but also being sure it wouldnt hibernate while streaming video. reboot-guard is what I needed since I did not want to deal with systemd inhibitor locks and dbus. I do have a background service that queries the tvheadend api. if there is a subscription or a recording going on it saves the info to a file that I'm monitoring with inotify watch. depending on the contents I tell reboot-guard to avoid hibernate or not. cheers.

ryran commented 7 years ago

@prietus Innnnnteresting! Thanks for sharing! By default, rguard only blocks poweroff, reboot, and halt targets ... did you have to uncomment hibernate.target to get this to work for you? E.g.:

def reboot_guard_systemd_refusemanualstart(self, enforce=True, targets=[]):
    """Block/unblock entering targets by way of RefuseManualStart=yes/no."""
    if not targets:
        targets = [
        'poweroff',
        'reboot',
        'halt',
        # 'hibernate',
        # 'hybrid-sleep',
        # 'suspend',
        ]
    reloadDaemon = False
    for t in targets:
        t += '.target'
        if enforce:
            if self.add_systemd_unit_start_block(t):
                reloadDaemon = True
        else:
            if self.del_systemd_unit_start_block(t):
                reloadDaemon = True
    if reloadDaemon:
        logging.debug("Reloading systemd via: systemctl daemon-reload")
        if not ret(subprocess.call(['systemctl', 'daemon-reload'])):
            logging.error("Unexpected error reloading systemd")
prietus commented 7 years ago

yeah I got hibernate working