Closed
Bug 1274054
Opened 9 years ago
Closed 9 years ago
Local webserver should generate local.conf.js automatically
Categories
(Tree Management :: Treeherder, defect)
Tree Management
Treeherder
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: wlach, Assigned: crosscent)
References
Details
Attachments
(1 file)
Right now we have a local webserver in treeherder that you can use for development:
http://treeherder.readthedocs.io/ui/installation.html#installation
You have to create a file called ui/js/config/local.conf.js for it to work though, which is a bit annoying. It really shouldn't be necessary either-- 99% of the time, we just want it to point to treeherder.mozilla.org for this case. We could handle the rare cases where we want to point against stage (treeherder.allizom.org) or some other server via command line options.
Steps to fixing this:
1. Make the url `/ui/js/config/local.conf.js` a custom endpoint for the node.js server, and make it return *either* the file `ui/js/config/local.conf.js` if it exists, or something like this if it doesn't:
```
window.thServiceDomain = 'https://treeherder.mozilla.org';
```
We can probably get the right behaviour for serving stuff just by modifying the `StaticServlet.prototype.handleRequest` method in web-server.js (in the root directory of treeherder).
2. Add optional command line flags called --stage (which will set window.thServiceDomain to point against 'https://treeherder.allizom.org' and --custom-server <url> (which will set the variable to <url>). Again this involves modifying web-server.js, I am pretty sure node.js has a library for command line processing.
3. Update the documentation to describe this new behavior (the files should be in docs/)
Assigning this to crosscent, who expressed some interest. :)
| Reporter | ||
Comment 1•9 years ago
|
||
Oh, we should also be able to delete this block of code once this is done:
https://github.com/mozilla/treeherder/blob/ae98e9d85943b579fdeb0f338388874fe22507c9/web-server.js#L273
Which is the preferred Node.js version, the LTS or Current?
Thanks!
| Reporter | ||
Comment 3•9 years ago
|
||
(In reply to crosscent from comment #2)
> Which is the preferred Node.js version, the LTS or Current?
>
> Thanks!
Ideally any code you write would work with either. This isn't a very complicated script so hopefully that's do-able without too much trouble. If you're getting set up for development, I'd start with the oldest supported LTS and go from there (since it's going to be the least featureful).
Hey Will, I was deciding on which library to use for command line processing, and it seems that minimist(https://www.npmjs.com/package/minimist) is more mature and does not release new versions extremely frequently. Do you think it is a good choice?
Comment 5•9 years ago
|
||
I'm also not overly attached to the web-server.js approach - if you happen to find another tool that can serve the files locally (and ideally support a few custom rules for this and other use-cases) that would work too. A Python-based tool would at least save having to install nodejs (I suspect more people have Python on their local machine natively than nodejs).
| Reporter | ||
Comment 6•9 years ago
|
||
(In reply to crosscent from comment #4)
> Hey Will, I was deciding on which library to use for command line
> processing, and it seems that
> minimist(https://www.npmjs.com/package/minimist) is more mature and does not
> release new versions extremely frequently. Do you think it is a good choice?
A cursory glance suggests it looks good to me!
(In reply to Ed Morley [:emorley] from comment #5)
> I'm also not overly attached to the web-server.js approach - if you happen
> to find another tool that can serve the files locally (and ideally support a
> few custom rules for this and other use-cases) that would work too. A
> Python-based tool would at least save having to install nodejs (I suspect
> more people have Python on their local machine natively than nodejs).
Well, we need node.js for js linting with eslint (as well as the frontend unit tests, though I question the value of those sometimes...), so I don't think it hurts to have to install it, really. I say let's keep this bug scoped to modifying the existing web-server.js, unless :crosscent really fancies rewriting it in python. :)
Comment 7•9 years ago
|
||
Attachment #8754433 -
Flags: review?(wlachance)
| Reporter | ||
Comment 9•9 years ago
|
||
Comment on attachment 8754433 [details] [review]
[treeherder] crosscent:bug1274054 > mozilla:master
This is great! Just a few small changes and we'll be good to land this, I think.
Attachment #8754433 -
Flags: review?(wlachance) → review-
| Assignee | ||
Comment 10•9 years ago
|
||
Will, since these commits are fairly small, and I have been crushing them into one single commit. This causes me having to force push, and your comment on previous commits are now ``outdated``. Is this the proper procedure? Or am I missing something?
Thanks!
Attachment #8754433 -
Flags: review- → review?(wlachance)
Comment 11•9 years ago
|
||
Commit pushed to master at https://github.com/mozilla/treeherder
https://github.com/mozilla/treeherder/commit/5053a342f09b63f6240bdb7bbf1a05af05107a7b
Bug 1274054 - Don't require a local.conf.js for local development
| Reporter | ||
Comment 12•9 years ago
|
||
Comment on attachment 8754433 [details] [review]
[treeherder] crosscent:bug1274054 > mozilla:master
This is great! The only thing that I felt needed to be changed was the commit message, which I changed to:
"Bug 1274054 - Don't require a local.conf.js for local development"
In general we try to make the commit messages (at least the first line) describe the functional change, rather than the specifics of what was done.
Attachment #8754433 -
Flags: review?(wlachance) → review+
| Reporter | ||
Updated•9 years ago
|
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Comment 13•9 years ago
|
||
Commit pushed to master at https://github.com/mozilla/treeherder
https://github.com/mozilla/treeherder/commit/901a45577770134f581ef044bcfe98a44a0ffe1d
Bug 1274054 - Move minimist from dependencies to devDependencies
Since it's only required when developing locally, so doesn't need to be
installed in production.
Blocks: 1276142
Updated•4 years ago
|
Component: Treeherder: Docs & Development → TreeHerder
You need to log in
before you can comment on or make changes to this bug.
Description
•