-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Optional: Cloud9 Development Environment
Make your free account with Cloud9 here. I found the easiest way to make a new account is to use the GitHub Account Creation tool found at the top of the page.
- Name and describe your new workspace
- Fork HospitalRun to your own repository in GitHub or elsewhere
- Clone HospitalRun from your own repository using the Clone from Git field
- Select Node.js from the Choose a template field to finish setting up your workspace
As Hospital Run is a growing project, the default 2gb diskspace of cloud9 workspaces won't be enough soon. You can increase diskpace up to 4gb and memory up to 1gb and still be in the free tier. This way you will decrease the execution time of the scripts described in the next steps
Open up a terminal in your cloud9 workspace. Make sure you are in the default directory (~/workspace). Next, source the cloud9 setup script by running:
source ./script/setupcloud9
Because of how nvm works in the cloud9 workspace, the script must be sourced. The script will setup nodejs to the correct version, install all the dependencies, setup couchdb and run the tests. The process takes about 25 minutes to run. When you are finished, the project will be ready to run.
Alternatively if you want to run just the basics so as to setup Hospital Run in cloud9, open up a terminal and source the cloud9 init script by running:
source ./script/initcloud9
. The script recongifures couchdb to run in the background and automates the steps described in the main installation guide. The process takes about 25 minutes to run. When you are finished, the project will be ready to run.
To start the ember app run ember serve --live-reload-port 8082
. This will start the hospitalrun application on the default preview port 8080 with the live reload server running on port 8082.
The application should be accessible now at https://hospitalrun-frontend-[YOUR-C9-USERNAME].c9users.io
If your application fails to load or respond to login, verify that the url has been made public. From the IDE click the share button in the top right corner. Check the boxes to make 'Application' and 'Files' public.
The setup script will start CouchDB automatically. However if you need to run CouchDB in the future, use the following command: sudo su couchdb -c /usr/bin/couchdb
. To test if CouchDB is running, run curl http://127.0.0.1:5984
. Use the sudo command every time you launch CouchDB, or the Ember app will fail to load.
Each time you work on this project, you're probably going to want to update your fork from HospitalRun's master. To do this, you need to set up HospitalRun as the upstream repository to your personal origin repo. Use this guide from GitHub for help on using forks correctly.
For your dependencies to work properly, they will need to be updated every time the package information is changed. To update them, run npm install
and bower install
from the root of your workspace.
Since Cloud9 only opens ports 8080, 8081, and 8082, you'll need a work around to view the GUI for CouchDB. Save the following code as /home/ubuntu/workspace/c9-couch.js
:
var http = require('http');
function onRequest(req,res) {
var postData = '';
req.addListener("data", function(postDataChunk) {
postData += postDataChunk;
});
req.addListener("end", function() {
makeCouchRequest(req.url, req.method, postData, function(cdata, ct) {
res.writeHead(200, {
'Content-Type': ct
});
res.end(cdata);
});
});
};
function makeCouchRequest(url,method,data, cb){
var req = http.request({
host: process.env.COUCHIP || "127.0.0.1",
port: process.env.COUCHPORT || 5984,
path: url,
method: method
},function(response){
var str='';
response.on('data', function(chunk){
str += chunk;
});
response.on('end', function(){
cb(str,response.headers['content-type']);
});
});
req.write(data);
req.end();
};
var server = http.createServer(onRequest); console.log('c9couch server created'); server.listen(process.env.PORT || 3000, process.env.IP || "0.0.0.0", function(){
var addr = server.address();
console.log("c9couch server listening at", addr.address + ":" + addr.port);
});
To access this webpage, make sure couchdb is running (see above) and run node c9-couch.js
. Then navigate to the page by going to https://-.c9users.io/_utils/ but do not forget to end the address with a slash!