How to create service entries in deepOfix (General Method)
INTRODUCTION
This simple How-to will help you to create service entries in deepOfix for any service. And you can also control (START, STOP) that service from EasyPush?.
STEP - 1
Create service entries
mkdir /etc/runit/<service>/ mkdir /etc/runit/<service>/log
STEP - 2
Create the log directory
mkdir /var/log/<service>/
STEP - 3
Create a run file. A run files executes the service. You need to know how to run your service in the foreground and have it log to standard error or standard output. The service needs to run in foreground so that it can be supervised by runit. It needs to log to stderr or stdout so that the logs can be maintained by svlogd.
You can use deepOfix run scripts a guide. The URLs above also have run-scripts for a lot of other services. Here is a general template you can always use:
#!/bin/sh exec 2>&1 exec <service> <options>
Put this in /etc/runit/<service>/run
STEP - 4
Create a run file for the log service:
#!/bin/sh exec svlogd -tt /var/log/<service>
Put this in /etc/runit/<service>/log/run. You will now see logs in the /var/log/<service>/ directory.
STEP - 5
Make your runscripts executable
chmod +x /etc/runit/<service>/run chmod +x /etc/runit/<service>/log/run
STEP - 6
Test your service:
cd /etc/runit/<service> ./run
Your service should start and run in the foreground. Press CTRL+C to stop. Similarly change to your log directory and test your log service as well.
STEP - 7
Activate the service:
ln -s /etc/runit/<service> /var/service/<service>
STEP - 8
Within the next 5 seconds, the service will start up and you should be able to monitor it:
sv s <service> ## Get the status sv d <service> ## Stop the service sv u <service> ## Start the service sv t <service> ## Restart the service
If you make a mistake in any of the run scripts, your service might crash and might keep getting restarted. The safe thing to do in such case would be to stop the service and check why its crashing. Run the service on the command-line and see if it runs or exits with some error.
STEP - 9
Want to monitor your service through EasyPush?? Its very easy. Just do the following:
echo "Service Name" > /etc/runit/<service>/NAME
It will now show up in the "Services" UI under "Server Control".
For more collection of ready to use service entries of popular services, please visit http://smarden.org/runit/runscripts.html. You can also use it for deepOfix also.
If you found this How-to very helpful to you. Please send acknowledgment at deepofix-users ( at ) list.deeproot.in. If you found any problem in this How-to or any query regarding this please feel free to shoot out any question at deepofix-users ( at ) list.deeproot.in.
