Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| docs:guide-developer:procd-init-script-example [2019/03/13 05:08] – [Service configuration with procd] bobafetthotmail | docs:guide-developer:procd-init-script-example [2024/02/10 17:38] (current) – [Enabling the service] systemcrash | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| <WRAP center round info 80%> | <WRAP center round info 80%> | ||
| - | This article is a mostly verbatim copy of https:// | + | This article is a mostly verbatim copy of [[https:// |
| - | It was adapted to use an equivalent shell script instead of a node javascript, because it's lighter and better for a simple testing setup on most OpenWrt devices. | + | It was adapted to use an equivalent shell script instead of NodeJS JavaScript, because it's lighter and better for a simple testing setup on most OpenWrt devices. |
| </ | </ | ||
| Line 15: | Line 15: | ||
| #these if statements will check input and place default values if no input is given | #these if statements will check input and place default values if no input is given | ||
| + | #they will also check if input is a number so you can call | ||
| + | #this script with just a time and it will still work correctly | ||
| + | |||
| if [ " | if [ " | ||
| - | name=" | + | |
| else | else | ||
| - | | + | if echo " |
| + | name=" | ||
| + | else | ||
| + | | ||
| + | fi | ||
| fi | fi | ||
| if [ " | if [ " | ||
| - | every=" | + | |
| else | else | ||
| - | every=" | + | |
| + | fi | ||
| + | |||
| + | if echo " | ||
| + | every=" | ||
| fi | fi | ||
| #endless loop, will print the message every X seconds as indicated in the $every variable | #endless loop, will print the message every X seconds as indicated in the $every variable | ||
| - | while [ 1 ] ; do | + | |
| - | | + | while [ 1 ]; do |
| - | | + | echo "Hey, $name, it's time to get up" |
| + | sleep $every | ||
| done | done | ||
| exit 0 | exit 0 | ||
| + | |||
| </ | </ | ||
| Line 68: | Line 81: | ||
| < | < | ||
| - | This will install a symlink for us in directory /etc/rc.d/ called | + | This will install a symlink for us in directory /etc/rc.d/ called |
| < | < | ||
| Line 141: | Line 154: | ||
| < | < | ||
| - | mynodeservice.hello=myservice | + | myservice.hello=myservice |
| - | mynodeservice.hello.name=Joost | + | myservice.hello.name=Joost |
| - | mynodeservice.hello.every=' | + | myservice.hello.every=' |
| </ | </ | ||
| Also single options can be requested | Also single options can be requested | ||
| Line 203: | Line 216: | ||
| ...</ | ...</ | ||
| - | With that line in place we are able to only restart the service whenever our configuration has changed. | + | With that line in place we are able to restart the service whenever |
| < | < | ||
| Line 213: | Line 226: | ||
| I’ll list a few here, but this is by no means covering everything. | I’ll list a few here, but this is by no means covering everything. | ||
| - | * **respawn**\\ respawn your service automatically when it died for some reason.\\ <code bash> | + | * **respawn**\\ respawn your service automatically when it terminates |
| ${respawn_threshold: | ${respawn_threshold: | ||
| - | ${respawn_timeout: | + | ${respawn_timeout: |
| * **pidfile**\\ Configure where to store the pid file \\ <code bash> | * **pidfile**\\ Configure where to store the pid file \\ <code bash> | ||