Meteor: downloading files during build process - build

Does anyone have experience managing the build process for a smart package, so that external files can be downloaded and served?
For example, a meteor smart package the wraps a javascript library can curl the library when the app is being built, and serve it directly from the server. This is useful for things like jquery-ui, the Ace editor, etc.
Specifically, I'm asking about the proper way to use Package._transitional_registerBuildPlugin, which was introduced in 0.6.5. Any examples would be great.
Grepping Meteor code only turns up things that add source handlers, so it's not very helpful for deciding what to do for downloading a file.
./packages/templating/package.js:Package._transitional_registerBuildPlugin({
./packages/stylus/package.js:Package._transitional_registerBuildPlugin({
./packages/meteor/package.js:Package._transitional_registerBuildPlugin({
./packages/coffeescript/package.js:Package._transitional_registerBuildPlugin({
./packages/less/package.js:Package._transitional_registerBuildPlugin({
A related question: what is a smart package allowed to write to its own .build folder?

I am aware that this is not exactly an answer for your question, but I couldn't resist posting this idea :)
The easiest thing that comes to my mind is to implement a simple "proxy" server using curl as you suggested. It could be more or less something like:
var spawn = Npm.require('child_process').spawn;
WebApp.connectHandlers.stack.splice (0, 0, {
route: '/jquery.js',
handle: function(req, res, next) {
spawn('curl', [
'https://code.jquery.com/jquery-1.10.2.min.js'
]).stdout.pipe(res);
res.writeHead(200, {
'Content-Type': 'text/javascript'
});
},
});
Though, it does not solve - out of the box - the problem of controlling the load order.
EDIT
If you prefer not to call curl every single time the file is requested by the user, you can always cache it somewhere on the server, right? Also this technique allows you to load additional libraries on demand, so only when they're actually needed. Note, that things like ace editor can be pretty heavy.

I ended up implementing this as a build plugin as part of my ShareJS smart package.. It's not the prettiest thing, but does what it needs to do. My approach is leading toward a generalized smart package for processing CDN downloads from Meteor packages.
I expect that the path to doing things like this will become easier and clearer as the build API becomes better documented.

Related

Choosing a good asynchronous solution for Django projects

I'm currently using Django served on Apache (mod_wsgi) for developing my apps. One of my favorite things is to 'fake' async requests with JavaScript's setInterval() function and AJAX to retrieve new data from database. For example:
// javascript
function someFunction() {
// do some stuff
setInterval(function() { fetchNewStuff() }, 1000); // run fetchNewStuff() every second
}
function fetchNewStuff() {
Dajaxice.main.fetch_new_stuff(fetch_new_stuff_callback, {'id':$(this).attr('user_id')});
}
function fetch_new_stuff_callback(data){
// append new stuff to my table, list or whatever in HTML page
}
As far as I am aware, this is perfectly fine for my needs. However, as my apps are growing bigger and more complex, this will eventually become too much hassle for both, my server and my clients, no matter how much I try to minimize transported data. Also, I cannot settle with the thing that in today's world I'm still 'faking' this :) So, I'd like to find some 'real' solution with push capabilities for my current and future projects.
I did try to google my problem and I have found many interesting stuff (Tornado, Nginx, Node.js, Twisted, etc.) but most of tutorials/articles/blogs are at least 6 months old and I believe that many things changed in that time. So far, I have tried to test Tornado and it was successful test, but I had some problems with setting it up on my production server. I also tried Node.js which is extremely simple since I know JavaScript very good, but then again, I'm not sure if it is a good solution.
My question here is - what would be the best thing (server, platform, framework, whatever) to implement in my current and future apps depending on this conditions:
easy to use (e.g. Node.js could fit in here)
eliminate 3rd party stuff as much as possible (some out-of-the-box solution, e.g. Django+Websockets and that's it [this was really just a silly example])
good documentation in use with Django (it would be perfect to have some real examples with my new technology and Django since I'm pretty much n00b for web servers and related stuff)
has a good perspective and future (I'm really looking to learn something which I will use a lot and which I wouldn't have to re-configure very often)
Thank you for your thoughts and any kind of help about this (links to some good, recently updated readings are more than welcome :)
You should have a look at django-socketio project, a Django app providing the features required to use websockets with Django via Socket.IO.
It uses gevent library along with socket.io.

C++ build artifacts management

We are moving our build and testing system to Jenkins, and are looking for an easy way (where we don't have to code all the logic ourselves) to manage the build artifacts.
Basically we need an organised way to store them in order by the type of the build, the user who built it and such for example:
johnd/nightly/r543241/win32/program.zip
johnd/nightly/trunk/lin64/program.tar.gz
master/release/2.1/win32/program.zip
This way we can upload when a build is complete, and retrieve the required artifact in the testing stage with ease.
Until now we simply stored the files in directories on NFS, but recently started considering an artifact manager. I've looked at Artifcatory, Archiva and Nexus. But all seem very Java centered or at least required maven to work with. Since I don't want to introduce more complexity (We mainly work with python, scons is our build tool) and I don't want to introduce maven to the mix, I'm looking for something that has an easy command line (or better REST/Python interface) to upload, download, manage artifacts.
If you don't use an artifact manager, but use some other clever method to manage your C++ artifacts for release/test needs I'd be happy to hear that also.
I have exactly the same issue. I didn't succeed to integrate artifactory easilly, so I forgot it.
For the moment I use the copy artefact plugin to copy by scp the file to an NFS share. But this is not a good solution since shares may be mounted differently on two machines, and windows cannot access them directly.
But a real artifact manager would be so such a good thing for our project.
In my previous job, I was using a documentation CMS (LiveLink) which provided good services:
- self organising folder.
- persistant url (we can move, rename folders and files, a public URL to a given files never changes, that was SOOO great : "http://server/go/123456789123456789" always pointed to the same file. So you just had to give this url to wget and you get the file
- file versionning.
- meta data, advanced search
I'm still searching such a solution in opensource software and don't find it.
In you just need to share artefact between two jobs, simple use the "copy artifact for another build" plugin. I use it to split my job into a a build job and a test job (actually there are 3 test jobs, one very fast done after each commit, one quite slow done every day, and one very slow done each week end).

What are some good libraries for accessing REST web clients from Scala?

I'd like to make a simple client that uses the Rdio API. What are my options as far as libraries go? I know of Dispatch and the WS library in Play.
Are there any others?
To be honest, I searched around and tried a few but found I was much happier using Apache HttpClient and Jackson (JSON), and jackson-module-scala directly, with some small helper classes.
Apache HttpComponents: http://hc.apache.org/
jackson-module-scala: https://github.com/FasterXML/jackson-module-scala
This is likely not the answer you were looking for, but I found that different REST APIs I was integrating with had various quirks and differences that made it hard to find the "perfect" abstraction library beyond that, and Scala makes it very easy to write your own useful traits to support this. E.g.:
val (statusCode, json) = getJsonFrom(url, ("Authorization" -> auth))
assert(statusCode == OK)
...
If you don't get a better answer, I can place some example code on GitHub when I get a chance if you are interested.

Simple HTTP Server lib

What is a good choice for a simple http Server lib? It doesn't need high performance. I rather look for something simple for some REST/JSON communication ("API").
It must be able though to work in a multithreaded environment and must be able to handle large POST request.
Any suggestions? I already tried cpp-netlib but this seems to be much too complicated for such an easy task...
Edit: I am looking for something really light-weight and simple. E.g. like Sinatra in the Ruby world. Poco is for me another example of a too heavy-weight library.
The first one that comes to mind is Poco Library ( http://pocoproject.org/ )
Cross platform, stable, well documented. While the library itself offers more than you probably need you can build and omit the portions you aren't planning on using to reduce bloat.
They have a fully featured Net library that includes several salient classes and utilities.
Here is a pdf of slides from that library, of particular interest is the HTTPServer class:
http://pocoproject.org/slides/200-Network.pdf
Not sure about large POST data, but I've previously used mongoose: https://github.com/cesanta/mongoose/.
If the LGPL license is unwanted there is a MIT fork from when the project was MIT that also add a C++ API https://github.com/bel2125/civetweb
I would encourage you to start with http server samples in boost.asio. They are so simple and easy to understand, that you should be able to easily extend them as needed.
However, if you want to jump onto something more polished than just sample code, I know of 3 http servers in C++ which you may like to try:
"x0 - HTTP Web Server Framework" to me personally this one seems most promising, because it's lightweight and simple
"highpower / xiva" is a simple http server framework for delivering notifications to browsers
"Pion, a project of Atomic Labs" is a part of elaborate framework for handling large amounts of data
Pretty late answer; but hope this helps.
For your interest of a server that can handle REST, here is the easiest HTTP Server library to use (in my opinion): https://github.com/yhirose/cpp-httplib.
For JSON parsing, you may search for another library to use it in conjunction.
Personally, I'd go for Arachnida but that might be because I wrote it.

Is anyone using a ColdFusion framework that has specific path requirements without mapping or locating resources in the server root?

Let me first say I am aware of this faq for Mach-II, which discusses using application specific mappings as a third option when:
locating the framework in the server root is not possible and
creating a server wide mapping to the Mach-II framework directory is impossible
Using application specific mappings would also work for other ColdFusion frameworks with similar requirements (ColdSpring). Here is my issue however: my (I should say "their") production servers are all running ColdFusion MX7, and application specific mappings were introduced in ColdFusion 8. I most likely will be unable to do option 1 or 2 because they involve creating server wide changes that could conflict with other applications (I don't have a final word on this but I am preparing for that to be the case).
That said, is there anybody out there who was in similar bind and has done an option 4, in any ColdFusion version, or with any similar framework? The only option 4 I can think of is modifying the entire framework to change this hardcoded path, and even if that worked it would be time consuming and risky. I'm fairly sure that if there was a simple modification or other simple solution it would already be included in the framework (maybe it's included in version 1.8 of Mach-II and I don't know about it yet).
Any thoughts on solving this problem or even unorthodox setups with libraries that have specific path requirements would be appreciated. Any thoughts from Team Mach-II would especially appreciated...we're on the same team here Matt! ;-)
EDIT
Apparently, the ColdBox framework includes a refactor.xml ANT task which includes a target that refactors the ColdBox code to use a different absolute path as a base along with several other useful refactoring targets. So problem solved for ColdBox users.
Looking at the build.xml for Mach-II (1.6 and 1.8) I don't see any target in there that would allow me to refactor the code. I thought about creating a feature request ticket for such a task for Mach-II but frankly I don't think creating such an ANT task is a big priority for the MachII team since the need really only relates to either
a) users of ColdFusion versions below 8
b) someone who wants to use multiple Mach-II versions in the same application, a use I doubt they want to support
The ColdSpring code I have doesn't come with any ANT tasks at all, although I do have unit tests, and I bet if I poked around the SVN I'd find a few build scripts.
Using Ant tasks to refactor and retest the code, or the simpler (and sort of cop out) solution of creating a separate ColdFusion instance for the application are the best answers I've been able to come up with. I don't need this application to exist in the shared scope of other applications, so my first solution is going to be to try and get a dedicated CF instance for this application.
I'm also going to look at the ColdBox refactor.xml ANT task however and see if I can modify it to work generically to recognize and refactor CFC references with modified absolute paths. If I complete this task I'll be sure to post the code somewhere and edit create an answer to link to it. If anybody else wants to take a crack at that or help me out with it feel free.
Until then I'll leave this question open and see if someone comes up with a better solution.
Fusebox is not so strict, I think.
In XML mode (maybe I call this not 100% correcly, just mean using the Application.cfm) it's just proper include in index.cfm, something like:
<cfinclude template="fusebox5/fusebox5.cfm" />
In non-XML mode it will need proper extending in the root Application.cfc:
<cfcomponent extends="path.to.fusebox5.Application" output="false">
All you need is to know the path.
Perhaps you could create a symbolic link and let the operating system resolve the issue for you?
I've been playing with FW/1 lately, and while it may look like you need to add a mapping and extend org.corfield.framework, you can actually move the framework.cfc file into your web root and just extend="framework". It's dead simple, and gets you straight into a great framework with no mess and very little overhead.
It should be as simple as dropping the 'MachII' folder at the root of your domain (i.e. example.com/MachII). No mappings are required to use Mach-II if you just deploy at the root of the domain of your website.
Also:
Please file a ticket for the ANT task you mentioned in your question. Team Mach-II would love to have this issue logged:
Enter a new ticket on the Mach-II Trac
If you want to tackle an ANT task for us, we can get stuff like this incorporated into the builds faster than waiting to for a Team member to work on the ticket. Code submissions from the community are welcome and appreciated.
We don't keep an eye on Stack Overflow very often so we invite you to join our official community group at called "Mach-II for ColdFusion" at Google Groups. The Google Group is the best place to ask questions or comments like this if you want feedback from the Team.