Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Readers > Kobo Reader > Kobo Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 10-27-2021, 03:11 AM   #1
dstaley
Member
dstaley began at the beginning.
 
dstaley's Avatar
 
Posts: 12
Karma: 10
Join Date: May 2020
Device: Kindle Voyage
Question How to start background processes at boot?

I have a background process that I'd like to run at boot. On Linux I'd typically do this with systemd, but obviously that's not an option. I know init.d can handle launching things, but it seems like most people use udev rules to run their background processes.

What are the different options I have to launch background processes at boot, and what are the pros/cons of each option?
dstaley is offline   Reply With Quote
Old 10-27-2021, 03:59 AM   #2
frostschutz
Linux User
frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.frostschutz ought to be getting tired of karma fortunes by now.
 
frostschutz's Avatar
 
Posts: 2,282
Karma: 6123806
Join Date: Sep 2010
Location: Heidelberg, Germany
Device: none
you can run it with an udev rule, but udev might trigger it multiple times (so you need some locking mechanism) and there's also a case where long running scripts are terminated, so the scripts might need to daemonize itself too.

so almost all my mods do it this way... trigger by udev, setsid, lock.

also your script may already run before kobo finished booting so the user partition maynot be mounted yet, so you have to wait for that too.

example

/etc/udev/rules.d/miniclock.rules
Code:
KERNEL=="loop0", ACTION=="add", RUN+="/usr/local/MiniClock/miniclock.sh"
/usr/local/MiniClock/miniclock.sh
Code:
#!/bin/sh

# udev kills slow scripts
udev_workarounds() {
    if [ "$SETSID" != "1" ]
    then
        SETSID=1 setsid "$0" "$@" &
        exit
    fi

    # udev might call twice
    mkdir /tmp/MiniClock || exit
}

# nickel stuff
wait_for_nickel() {
    while ! pidof nickel || ! grep /mnt/onboard /proc/mounts
    do
      	sleep 5
    done
}

udev_workarounds
wait_for_nickel

# do your stuff past this point
there may be better or different methods, I don't know, this approach has worked well for me so far

using udev rules is nice since you can just add those files. there's no need to modify existing files. you can tamper the Kobo's rc scripts too but if there are two different mods that want to do that, they might be in conflict with one another, and the risk of breaking the boot process is higher

Last edited by frostschutz; 10-27-2021 at 04:02 AM.
frostschutz is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mac High Sierra : background process at boot reinsley Calibre 2 02-05-2018 11:31 AM
Make CC not start on boot roadrunnerm Calibre Companion 4 04-08-2016 10:03 AM
Calibre start at boot on Ubuntu 12.04 ? user68 Calibre 2 06-08-2012 05:12 PM
DR800 How to start a background process? CoolDragon iRex 1 04-29-2010 04:16 PM
Calibre appears in processes but does not start in vista vrf3 Calibre 10 03-23-2009 01:06 AM


All times are GMT -4. The time now is 05:30 PM.


MobileRead.com is a privately owned, operated and funded community.