#!/bin/sh/etc/rc.common
Start=90
Stop=90
Service=app
Use_procd=1
Start_service ()
{Procd_open_instance
Procd_set_param Command/usr/sbin/app
Procd_set_param respawn
Procd_close_instance
}
Service_triggers ()
{
Procd_add_reload_trigger "Config_file_name"
}
Reload_service ()
{
}
Stop_service ()
{
}
Explain
1. Start_service () for the registration service to PROCD, if your application does not have a configuration file, as long as the implementation of Start_service (), Procd_set_param settings set many parameters, command for their own application path, Respawn can detect their own applications, if the hang off can be restarted, you can set the restart interval, other parameters can be consulted.
2. Stop_service () This is called after ProCD Kill your application, and if your application is turned off, you need some cleanup work to implement this.
3. Service_triggers () If your application needs to correlate a configuration file test, (you need to put it in the/etc/config/directory), you can track the file changes, if the file changes, call Reload_service (). You can also add a trace network modification in service_triggers, or you can track multiple profiles at the same time.
4. Reload_service () configuration file changes, you need to call this function, you can implement the function according to their own needs.
Note: The difference between start and reload is that start generally refers to application startup, reload generally refers to just reloading the part related to configuration file changes and not restarting the entire application. This approach should be recommended, and it is also possible if you restart the application in reload.
General profile file changes are judged by MD5 values,/sbin/reload_config, and the contents are as follows
#!/bin/sh
Md5file=/var/run/config.md5
[-F $MD 5FILE] && {
For C in ' Md5sum-c $MD 5FILE 2>/dev/null| grep FAILED | cut-d:-f1 '; Todo
Ubus Call Service event "{\" type\ ": \" config.change\ ", \" data\ ": {\" package\ ": \" $ (basename $c) \ "}}"
Done
}
md5sum/etc/config/* > $MD 5FILE
is to invoke the PROCD registered service event event, such as a Web page modification configuration, which is invoked via RPCD/sbin/reload_config