Andre_Leonardo
Posts: 59
Joined: Wed Nov 12, 2014 1:47 am

PIGPIO daemon

Thu Mar 12, 2015 10:12 am

How to run the pigpio daemon when pi boots to use with python scripts :?:

User avatar
joan
Posts: 14004
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: PIGPIO daemon

Thu Mar 12, 2015 11:17 am

There are several ways.

One of the simplest is adding the following line to the root crontab.

Code: Select all

@reboot              /usr/local/bin/pigpiod
Use

sudo crontab -e

to edit the root crontab and add that line to the end. Then ctrl-o return ctrl-x to exit.

Andre_Leonardo
Posts: 59
Joined: Wed Nov 12, 2014 1:47 am

Re: PIGPIO daemon

Thu Mar 12, 2015 11:27 am

Thnx for the help, What are the other possible methods

User avatar
B.Goode
Posts: 7857
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: PIGPIO daemon

Thu Mar 12, 2015 11:34 am

You've had advice direct from the developer/maintainer of the package you want to run: I'd be inclined to listen...

If you really want an alternative you could see what the Raspberry Pi Foundation have to say in their documentation: http://www.raspberrypi.org/documentatio ... c-local.md

User avatar
DougieLawson
Posts: 35347
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: PIGPIO daemon

Thu Mar 12, 2015 12:07 pm

joan wrote:There are several ways.

One of the simplest is adding the following line to the root crontab.

Code: Select all

@reboot              /usr/local/bin/pigpiod
Use

sudo crontab -e

to edit the root crontab and add that line to the end. Then ctrl-o return ctrl-x to exit.
I'd do it with a /etc/init.d/ script and update-rc.d.

# sudo cp /etc/init.d/skeleton /etc/init.d/pigpiod or copy my version down there ... VVV
sudo chmod 755 pigpiod
sudo nano /etc/init.d/pigpiod

Code: Select all

#! /bin/sh
### BEGIN INIT INFO
# Provides:          pigpiod
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the pigpio daemon
# Description:       Start the pigpio daemon during system boot
#                    
### END INIT INFO

# Author: Joan <Joan on http://raspberrypi.org/forums>
#

# Do NOT "set -e" # AND NOBODY KNOWS WHY

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
DESC="pigpio daemon"
NAME=pigpiod
DAEMON=/usr/local/bin/$NAME
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
                || return 1
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
                $DAEMON_ARGS \
                || return 2
}

#
# Function that stops the daemon/service
#
do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
        RETVAL="$?"
        [ "$RETVAL" = 2 ] && return 2
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
        [ "$?" = 2 ] && return 2
        rm -f $PIDFILE
        return "$RETVAL"
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  status)
        status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
        ;;
  restart)
        log_daemon_msg "Restarting $DESC" "$NAME"
        do_stop
        case "$?" in
          0|1)
                do_start
                case "$?" in
                        0) log_end_msg 0 ;;
                        1) log_end_msg 1 ;; # Old process is still running
                        *) log_end_msg 1 ;; # Failed to start
                esac
                ;;
          *)
                # Failed to stop
                log_end_msg 1
                ;;
        esac
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
        exit 3
        ;;
esac

:
I've stripped out the reload & force-reload functions and lots of the junk in that version.
sudo update-rc.d pigpiod defaults
sudo update-rc.d pigpiod enable
Note: Having anything remotely humorous in your signature is completely banned on this forum.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

daverck
Posts: 6
Joined: Sun Oct 25, 2015 11:59 am

Re: PIGPIO daemon

Sun Jun 26, 2016 9:42 pm

thank you :)

mmweb
Posts: 1
Joined: Mon Jun 27, 2016 3:54 am

Re: PIGPIO daemon

Mon Jun 27, 2016 4:02 am

While using an RPi 3 Model B, my executable for pigpiod was stored at /usr/bin/ instead of /usr/local/bin/. I thought I'd add to this thread that you can make sure that you are using the correct path in the root crontab by running

Code: Select all

whereis pigpiod
.

raspdroid
Posts: 1582
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Re: PIGPIO daemon

Thu Sep 08, 2016 10:09 pm

Hello,

viewtopic.php?p=717198#p717198

I have used this script with DAEMON=/usr/bin/$NAME
[email protected]:~ $ whereis pigpiod
pigpiod: /usr/bin/pigpiod /usr/man/man1/pigpiod.1.gz
But it is not possible to connect from a remote client via socket. I have disable to connect.
868 sudo update-rc.d pigpiod disable
869 sudo reboot
870 sudo pigpiod
This rc file disable the socket interface ?

Best regards

jcummings
Posts: 1
Joined: Fri May 12, 2017 3:17 pm

Re: PIGPIO daemon

Fri May 12, 2017 3:23 pm

On Raspbian 8 (jessie) with pigpio version 1.60-1 from an apt-get install, I was able to simple run:

Code: Select all

sudo systemctl enable pigpiod.service

tomfitzphilly
Posts: 8
Joined: Thu Jan 11, 2018 2:40 am

Re: PIGPIO daemon

Sat Mar 24, 2018 3:58 am

Thanks so much all. on the rpi3 jessie stretch it is, indeed, at /usr/bin

Return to “Python”