When working with runit on Ubuntu 12.04, the error "unable to open supervise/ok: file does not exist" typically indicates a service initialization problem. The supervise/ok file is crucial as it's created by runit when a service is properly started and supervised.
First, verify your service directory structure. A properly configured service should have:
/etc/sv/myapp/
├── run
├── log/
│ └── run
└── config (optional)
Your symlink creation seems correct:
sudo ln -s /etc/sv/myapp /service/myapp
Common causes for this error include:
- Incorrect permissions on /service directory (should be 1755)
- Missing execute permission on run scripts
- Incorrect ownership (should be root:root)
Run these commands to verify:
ls -ld /service
ls -l /etc/sv/myapp/run
ls -l /etc/sv/myapp/log/run
For manual debugging, try:
cd /etc/sv/myapp
./run
If the script runs manually but not via runit, check for:
- Environment variable differences
- Path issues in your run script
- Missing dependencies
While restarting svscan might help, a more thorough approach is:
sudo pkill svscan
sudo /usr/bin/svscanboot &
Then watch the logs:
tail -f /var/log/syslog | grep svscan
Here's a complete working example for a simple service:
# /etc/sv/myservice/run
#!/bin/sh
exec 2>&1
exec /usr/local/bin/myservice --config /etc/myservice.conf
Log directory setup:
# /etc/sv/myservice/log/run
#!/bin/sh
exec svlogd -tt /var/log/myservice
Set permissions:
sudo chmod +x /etc/sv/myservice/run
sudo chmod +x /etc/sv/myservice/log/run
sudo chown -R root:root /etc/sv/myservice
If issues persist:
- Verify runit is properly installed:
dpkg -l | grep runit
- Check for conflicts with other init systems
- Consider upgrading from Ubuntu 12.04 (EOL)
The error message you're encountering typically occurs when runit's supervision tree isn't properly initialized. The supervise/ok
file is a critical component that runit creates when a service is correctly set up and running.
For runit to work properly, your service directory should have this basic structure:
/etc/sv/myapp/
├── run
├── log/
│ └── run
└── config (optional)
When the supervise/ok
file is missing, it usually indicates one of these scenarios:
- The service was never properly started
- Permissions prevent runit from creating the supervise directory
- The symlink wasn't created correctly
- svscan isn't running
1. Verify Service Directory Structure
First, ensure your run script is executable:
chmod +x /etc/sv/myapp/run
chmod +x /etc/sv/myapp/log/run
2. Check Symlink Creation
Instead of creating the symlink manually, use runit's recommended approach:
ln -s /etc/sv/myapp /service/
3. Validate svscan Operation
Ensure svscan is actually running:
ps aux | grep svscan
If it's not running, start it properly:
sudo /usr/bin/svscanboot &
4. Force Service Recreation
Sometimes removing and recreating the service helps:
sudo rm -rf /service/myapp
sudo ln -s /etc/sv/myapp /service/
sudo sv restart myapp
For deeper investigation, check the supervise directory permissions:
ls -la /etc/sv/myapp/supervise
The directory should be owned by root and have these permissions:
drwx------ 2 root root 4096 Apr 10 10:00 supervise
Here's a complete example for a simple service:
# /etc/sv/example/run
#!/bin/sh
exec 2>&1
exec /usr/local/bin/example-service --config /etc/example.conf
And the log runner:
# /etc/sv/example/log/run
#!/bin/sh
exec svlogd -tt /var/log/example
If the issue persists, try using runsvdir directly for testing:
sudo runsvdir /service &
This can help determine if the issue is with svscanboot or the service configuration itself.