Skip to main content
procd is OpenWrt’s PID 1 init system. It handles early boot, service supervision, hotplug events, and integrates with ubus to expose a service management API.

Components

ComponentDescription
initRuns as PID 1 during early boot, sets up the system
procdService supervisor: starts, monitors, and restarts services
udevtriggerReplays udev events on boot to trigger hotplug
upgradedHandles sysupgrade coordination
askfirstSpawns a getty/shell on the console at first boot
Additional optional packages:
PackageDescription
procd-ujailProcess jail helper using Linux namespaces
procd-seccompSeccomp syscall filter support
uxcContainer management using procd-ujail

Service Script Structure

All init scripts live in /etc/init.d/ and use the /etc/rc.common framework:
#!/bin/sh /etc/rc.common

USE_PROCD=1
START=95
STOP=05

start_service() {
    procd_open_instance
    procd_set_param command /usr/sbin/my-daemon --foreground
    procd_set_param env MY_VAR=value
    procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
    procd_set_param limits core="unlimited"
    procd_set_param file /etc/config/my-service
    procd_set_param stdout 1
    procd_set_param stderr 1
    procd_close_instance
}

procd_set_param Parameters

ParameterDescription
commandThe command and arguments to execute
envEnvironment variable(s) to set
respawn [threshold] [timeout] [retry]Auto-restart settings. threshold: crash-free seconds before reset. timeout: seconds between restarts. retry: max restarts before giving up (0 = infinite).
limitsProcess resource limits (core, nofile, nproc, etc.)
fileConfig file(s) to watch; service restarts when these change
netdevNetwork interface to watch
stdoutRedirect stdout to syslog (1=enable)
stderrRedirect stderr to syslog (1=enable)
pidfilePath to write the service PID
userRun the service as this user
groupRun the service as this group

START and STOP Values

START and STOP are integer ordering values (0–99). Services with lower START values start earlier. STOP is used for shutdown ordering.

Init Script Commands

# Enable a service (creates symlink in /etc/rc.d/)
/etc/init.d/my-service enable

# Disable a service
/etc/init.d/my-service disable

# Start / stop / restart
/etc/init.d/my-service start
/etc/init.d/my-service stop
/etc/init.d/my-service restart

# Reload configuration without restarting
/etc/init.d/my-service reload

# Show status
/etc/init.d/my-service status
Enabling a service creates a symlink:
/etc/rc.d/S95my-service -> /etc/init.d/my-service

procd via ubus

procd exposes a service object on ubus for runtime service management:
# List all services and their instances
ubus call service list

# Get details for a specific service
ubus call service list '{"name":"dnsmasq"}'

# Start a service instance programmatically
ubus call service set '{
  "name": "my-app",
  "instances": {
    "instance1": {
      "command": ["/usr/bin/my-app", "--arg1"]
    }
  }
}'

# Delete a service
ubus call service delete '{"name":"my-app"}'

# Send a signal to a service
ubus call service signal '{"name":"my-app","signal":15}'

Hotplug Subsystem

procd handles hotplug events (USB insertion, network link changes, etc.) by executing scripts from:
/etc/hotplug.d/<subsystem>/
The <subsystem> matches the kernel’s hotplug subsystem name:
SubsystemTriggered by
blockBlock devices (USB storage, SD cards)
netNetwork interface changes
usbUSB device insertion/removal
buttonGPIO button events
ieee80211Wi-Fi radio events
Example hotplug script:
#!/bin/sh
# /etc/hotplug.d/block/10-mount

[ "$ACTION" = "add" ] || exit 0
[ -b "/dev/$DEVNAME" ] || exit 0

mkdir -p /mnt/$DEVNAME
mount /dev/$DEVNAME /mnt/$DEVNAME

Available Hotplug Variables

VariableDescription
$ACTIONadd, remove, change, bind, unbind
$DEVNAMEDevice name (e.g., sda1, eth1)
$SUBSYSTEMKernel subsystem
$DEVTYPEDevice type (e.g., disk, partition)

Minimal Service Example

#!/bin/sh /etc/rc.common
# /etc/init.d/hello

USE_PROCD=1
START=99
STOP=01

start_service() {
    procd_open_instance
    procd_set_param command /bin/sh -c 'while true; do echo hello; sleep 60; done'
    procd_set_param respawn
    procd_close_instance
}
After placing this file at /etc/init.d/hello:
chmod +x /etc/init.d/hello
/etc/init.d/hello enable
/etc/init.d/hello start