updating initialize function to include user_data

This commit is contained in:
Thomas Harvey 2017-10-23 15:53:49 -04:00
parent 734eaeac2f
commit 0a4162400b
3 changed files with 7 additions and 29 deletions

View File

@ -10,14 +10,14 @@ function usedMemoryPercent () {
function buildRunners () {
baseName="crunner0";
namePrefix="cubs";
namePrefix="crunner-batch-${RANDOM}";
runners="";
usedMemoryPercent;
# maxMemoryUsage must be defined
until [[ $memory -gt $maxMemoryUsage ]]; do
runnerName="${namePrefix}${RANDOM}";
runnerName="${namePrefix}-id-${RANDOM}";
lxc-start-ephemeral -o $baseName -n $runnerName --union-type overlayfs -d;
if [[ $? -eq 0 ]]; then
@ -27,4 +27,6 @@ function buildRunners () {
done
}
buildRunners;
# Add curl to manager here. Sending status report to manager
exit 0;

View File

@ -1,25 +0,0 @@
Oct 20 21:52:16 dev--CLW10-3066 crontab[1885]: (virt) REPLACE (virt)
Oct 20 21:52:37 dev--CLW10-3066 crontab[2166]: (virt) LIST (virt)
Oct 20 21:53:03 dev--CLW10-3066 crontab[2168]: (virt) LIST (virt)
Oct 20 22:01:01 dev--CLW10-3066 CRON[18873]: (virt) CMD (source /home/virt/allocate_runners.sh)
Oct 20 23:01:01 dev--CLW10-3066 CRON[1867]: (virt) CMD (source /home/virt/allocate_runners.sh)
ALL CRON
Oct 20 21:52:13 dev--CLW10-3066 cron[1443]: (CRON) INFO (pidfile fd = 3)
Oct 20 21:52:13 dev--CLW10-3066 cron[1443]: (CRON) INFO (Running @reboot jobs)
Oct 20 21:52:16 dev--CLW10-3066 crontab[1885]: (virt) REPLACE (virt)
Oct 20 21:52:37 dev--CLW10-3066 crontab[2166]: (virt) LIST (virt)
Oct 20 21:53:03 dev--CLW10-3066 crontab[2168]: (virt) LIST (virt)
Oct 20 22:01:01 dev--CLW10-3066 CRON[18873]: (virt) CMD (source /home/virt/allocate_runners.sh)
Oct 20 22:01:01 dev--CLW10-3066 CRON[18870]: (CRON) info (No MTA installed, discarding output)
Oct 20 22:17:01 dev--CLW10-3066 cron[1443]: Authentication token is no longer valid; new one required
Oct 20 22:17:01 dev--CLW10-3066 CRON[18913]: Authentication token is no longer valid; new one required
Oct 20 22:17:53 dev--CLW10-3066 cron[1393]: (CRON) INFO (pidfile fd = 3)
Oct 20 22:17:53 dev--CLW10-3066 cron[1393]: (CRON) INFO (Running @reboot jobs)
Oct 20 23:01:01 dev--CLW10-3066 CRON[1867]: (virt) CMD (source /home/virt/allocate_runners.sh)
Oct 20 23:01:01 dev--CLW10-3066 CRON[1865]: (CRON) info (No MTA installed, discarding output)
Oct 20 23:17:01 dev--CLW10-3066 cron[1393]: Authentication token is no longer valid; new one required
Oct 20 23:17:01 dev--CLW10-3066 CRON[1897]: Authentication token is no longer valid; new one required

View File

@ -209,6 +209,7 @@ var Worker = (function(){
name: config.tagPrefix + (config.version+"") + '-' + utils.uuid(),
image: config.image,
size: config.size,
user_data: proto.__buildCommand(config.maxMemoryUsage || 80),
onCreate: function(data){
doapi.dropletSetTag(
config.tagPrefix + config.version,
@ -224,8 +225,8 @@ var Worker = (function(){
proto.__buildCommand = function(file, maxMemoryUsage){
var command = `echo "export PATH=\${PATH};export maxMemoryUsage=${maxMemoryUsage};`;
command += `echo '${file.toString("base64")}'|base64 --decode|bash" | cat > /home/virt/allocate_runners.sh`;
command += ` && echo "*/1 * * * * source /home/virt/allocate_runners.sh >> /home/virt/allocate_runners.log 2>&1" | crontab -;`;
command += `echo '${file.toString("base64")}'|base64 --decode|bash" | cat > /home/virt/allocate_runners.sh && chmod virt +x /home/virt/allocate_runners.sh`;
command += ` && echo "*/1 * * * * /home/virt/allocate_runners.sh >> /home/virt/allocate_runners.log 2>&1" | crontab -u virt -;`;
return command;
};