Skip to content

Commit

Permalink
Added dumb-init. Used a couple lodash functions to replace some crazy…
Browse files Browse the repository at this point in the history
… loops.
  • Loading branch information
kylehuntsman committed Mar 22, 2016
1 parent c01d65c commit abf02be
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ RUN apt-get update --fix-missing && \
lxc \
aufs-tools && \
apt-get clean && \
rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*
rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* && \
wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.0.0/dumb-init_1.0.0_amd64 && \
chmod +x /usr/bin/dumb-init

##SSH Folder for known_hosts
RUN mkdir -p /root/.ssh && chmod 500 /root/.ssh && chown -R root:root /root/.ssh
Expand Down Expand Up @@ -70,5 +72,6 @@ EXPOSE 8080

VOLUME /var/lib/docker

ENTRYPOINT ["/usr/sbin/supervisord-wrapper.sh"]
ENTRYPOINT ["/usr/bin/dumb-init", "/usr/sbin/supervisord-wrapper.sh"]

CMD [""]
33 changes: 14 additions & 19 deletions lib/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,18 +446,20 @@ Factory.prototype.createJob = function createJob(req, res, context, next) {
* @returns [] of jobs
*/
Factory.prototype.getJobs = function getJobs() {
var datastore = this.jobs.get();
var keys = Object.keys(datastore);

var jobs = [];
for(var i = 0; i < keys.length; i++) {
if(keys[i]) {
var id = keys[i];
jobs.push(datastore[id]);
}
}
// var datastore = this.jobs.get();
// var keys = Object.keys(datastore);

// var jobs = [];
// for(var i = 0; i < keys.length; i++) {
// if(keys[i]) {
// var id = keys[i];
// jobs.push(datastore[id]);
// }
// }

return jobs;
// return jobs;

return _.values(this.jobs.get());
};

/**
Expand All @@ -469,14 +471,7 @@ Factory.prototype.getJobs = function getJobs() {
Factory.prototype.coalesceRequests = function coalesceRequests(res, context) {
// Check for duplicate context in an array of jobs
function checkIfDuplicate(jobs) {
for (var j = 0; j < jobs.length; j++) {
var otherJob = jobs[j];
if(JSON.stringify(context) === JSON.stringify(otherJob.context)) {
return otherJob;
}
}

return false;
return _.find(jobs, {'context': context});
}

// Return an array of running jobs
Expand Down

0 comments on commit abf02be

Please sign in to comment.