Skip to content

Instantly share code, notes, and snippets.

@dsamarin
Created January 2, 2012 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsamarin/1550122 to your computer and use it in GitHub Desktop.
Save dsamarin/1550122 to your computer and use it in GitHub Desktop.
Hub.init = function() {
this.load_config (function() {
this.start_server ();
});
};
Hub.load_config = function(callback) {
var config, locations, self = this;
config = new HubConfig;
locations = ["~/.diaptoval/config.json", "/etc/diaptoval/config.json"];
// Continuation-passing style
(function retry() {
if (!locations.length) {
console.error ("No configuration file found");
return;
}
config.load_file (locations.shift (), function (success) {
if (success) {
self.config = config;
callback.call (self);
} else {
retry ();
}
});
})();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment