jagthedrummer / canary-ember

An ember front end to data produced by canary.io
16 stars 3 forks source link

Make API and URLs configurable #7

Closed blalor closed 9 years ago

blalor commented 10 years ago

It'd be great if I could just specify the base URL for the Canary API and the location of the JSON file containing check definitions in a config file. Right now I have to hack application.js and measurements.js (?) when I want to use a private instance of Canary.

jagthedrummer commented 10 years ago

Yeah, this is a great idea. It should probably be a 'per environment' type of a build variable.

blalor commented 10 years ago

I was actually thinking it should be run-time config. That way you can package up the dist dir and change the config afterwards, without having to re-run ember build.

jagthedrummer commented 10 years ago

Ah, I see. That makes sense. Do you have an idea of how/where to do that?

blalor commented 10 years ago

No, I'm afraid not. Ember's pure voodoo to me. This model is used by applications like Grafana and Kibana, however; not sure if that'll be of use…

ryoe commented 10 years ago

Would it work to use environment variables?

I don't know ember well enough to know how to do it, but in node world something like this would work.

As part of the canary-ember startup process do something like this...

export CANARY_EMBER_API_HOST="http://mycanaryapi/"
export CANARY_EMBER_CHECK_HOST="http://mycanarychecks/"

Then in application.js do something like

host :  process.env.CANARY_EMBER_CHECK_HOST || 'https://s3.amazonaws.com/'

And in measurement.js do something like

host :  process.env.CANARY_EMBER_API_HOST || 'https://api.canary.io/'
blalor commented 10 years ago

That only works if Node is evaluating the JS. The output of the build process is a static set of HTML, CSS and JS files. They can be served by Apache or Nginx. The environment would have no effect on those static files. Instead, the application should read its config from a file that the browser can retrieve and interpret.

ryoe commented 10 years ago

Thanks for clarifying that @blalor. I'll learn how this Ember stuff works eventually.

So, you'd like a config file that should be read at initial load, if present, and used to set run-time values for the canary api and checks hosts?

Would hand-crafted JSON be OK? Maybe something like this proposed canary-hosts.json:

{
  "api": "http://mycanaryapi/",
  "checks": "http://mycanarychecks/" 
}
blalor commented 10 years ago

Yep, that’s exactly correct, Rick. Hand-crafted JSON is perfect; it’ll be created via Chef, most likely. :-)

jagthedrummer commented 9 years ago

With the main canary project being in transition and the JSON endpoint no longer running I'm just going to close this. Thanks to everyone who pitched in on this project!

gorsuch commented 9 years ago

<3