Skip to content

How to run maphub in development mode

behas edited this page Aug 15, 2012 · 1 revision

Follow these guidelines if you want to run maphub locally; e.g. for contributing code. Running in development mode ensures that the application is reloaded whenever you change a source file. This makes changes available in your browser right away.

Prerequisites

  • Ruby 1.9.3
  • Ruby Gems
  • Java VM

Installing maphub

The following instructions were tested with ruby 1.9.3 and gem 1.8. We recommend RVM for controlling your local Ruby environments.

ruby -v
gem -v

We also recommend to create a separate RVM Gemset for the maphub portal:

rvm gemset create maphub
rvm gemset use maphub

Optionally you can set maphub to be the default gemset

rvm use 1.9.3-head@maphub --default

Clone the maphub code on your local machine:

git clone git@github.com:maphub/maphub-portal.git

Update your gem tool with gem update --system and install the bundler gem with gem install bundler. cd to the project folder and run to install all necessary gems for the maphub tool.

bundle install

Now, start the Solr engine.

bundle exec rake sunspot:solr:start

Then, run the Rails application, probably in a separate console window.

rails server

Create the database and add some test data (or see here for more options to add test data):

rake db:migrate
rake db:seed

Finally, open http://localhost:3000/ in your browser and log into maphub with user1@example.com and test. You're done. Read on for optional steps and further info.

Deploying on port 80

The server can run on port 80, but in most cases it needs root permission to do so. Execute the following to have the server run in background:

rvmsudo rails server -p 80

Once you've made sure that works, cancel it and enter:

nohup rvmsudo rails server -p 80 &> /dev/null 2> /dev/null &

If the server runs normally, you're finished. If not, it's still asking for the password. Bring the process to the foreground with fg and type in the password.

Now we need to suspend the process and get it to the background again. Press Ctrl-Z and enter bg.

Updating the database / Reindexing data

If you made some changes to the database or first create the database, run the following command, which recreates the database and adds sample data.

bundle exec rake db:drop && bundle exec rake db:migrate && bundle exec rake db:seed

Sunspot also needs to be reindexed if its models have changed:

bundle exec rake sunspot:solr:reindex

Shutting down

When you're shutting down, stop Solr with

bundle exec rake sunspot:solr:stop

Also stop the rails server command.

Troubleshooting

** The server doesn't seem to be recognizing the new javascript that I've written **

When switching between developer and production mode, make sure you

rm -rf public/assets

This way, caching errors from obsolete JS files can be prevented.