Last active
October 28, 2017 17:02
-
-
Save joustava/65599194ca6b449f22e031ffa53d3eaa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh /etc/rc.common | |
USE_PROCD=1 | |
START=95 | |
STOP=01 | |
start_service() { | |
procd_open_instance | |
procd_set_param command /usr/bin/node "/var/mynodeservice.js" | |
procd_close_instance | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh /etc/rc.common | |
USE_PROCD=1 | |
START=95 | |
STOP=01 | |
CONFIGURATION=mynodeservice | |
start_service() { | |
# Reading config | |
config_load "${CONFIGURATION}" | |
local name | |
local every | |
config_get name hello name | |
config_get every hello every | |
procd_open_instance | |
# pass config to script on start | |
procd_set_param command /usr/bin/node "/var/mynodeservice.js" "$name" "$every" | |
procd_set_param file /etc/config/mynodeservice | |
procd_set_param stdout 1 | |
procd_set_param stderr 1 | |
procd_close_instance | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh /etc/rc.common | |
USE_PROCD=1 | |
START=95 | |
STOP=01 | |
start_service() { | |
procd_open_instance | |
procd_set_param command /usr/bin/node "/var/mynodeservice.js" | |
procd_set_param stdout 1 | |
procd_set_param stderr 1 | |
procd_close_instance | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
config mynodeservice 'hello' | |
option name 'Joost' | |
option every '5000' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* /var/mynodeservice.js | |
*/ | |
const name = process.argv[2] || 'You'; | |
const every = process.argv[3] || 5000; | |
setInterval(function(){ | |
console.log(`Hey, ${name}, it's time to get up`); | |
}, every); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment