Skip to content

Instantly share code, notes, and snippets.

@ppeble
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save ppeble/28abac1a1312941b76c6 to your computer and use it in GitHub Desktop.

Select an option

Save ppeble/28abac1a1312941b76c6 to your computer and use it in GitHub Desktop.
Marketplace-web development setup for service-host vm
Unfortunately there are multiple steps that must be taken to fully set up the environment for marketplace-web development. This is a living document, please let me know if you hit any snags so it can be updated.
These instructions assume that you have fully set up the service-host vm (https://github.com/sittercity/service-host) via the README. If you have any issues setting it up please contact DevOps.
Once you are logged into your VM you must complete all of these steps. These are all one-time steps.
0) Before anything else, make sure that you clone 'stormtrooper' from github into the '~/dev' directory on the VM. This will be important for later steps.
1) Pull all of the variables found at https://gist.github.com/ptrimble/3dd85c7704398f008746 and place it in a file in your home directory on the VM. I recommend that you name it '.sc_service-config' but it can be whatever you want. Add the following line to your ~/.zshrc file:
```source ~/.sc_service_config```
If you used a different name for your file then make sure to use the right one.
This will set up your environment variables that are required for running the various parts of our infrastructure locally. You must log off and log back in for this to take effect (or just manually run the command in your current window).
2) Go to ~/dev and clone the sc-public-api rep: https://github.com/sittercity/sc-public-api
Run through the setup information in the README of that project and make sure that you can launch it at the end of the process without errors.
3) Go to ~/dev and clone marketplace-web from github (https://github.com/sittercity/marketplace-web). Run 'bundle install' like normal.
4) While logged into the service-host VM run ```ssh empire```. Change directory to '/mnt' and list everything in it. If it is empty, log off of the empire container (by running 'exit') and run the following two commands:
a) sudo lxc-stop -nempire
b) sudo lxc-start -dn empire
Then log back into the empire container and go back to mount. You should see lots of directories in there for various projects.
Clone two repos into the '/mnt' directory on the empire container:
a) git clone git@github.com:sittercity/sittercity.git
b) git clone git@github.com:sittercity/sso-api.git
Run 'bundle install' for both projects. In one window run 'sso_start' inside the sso-api directory to start the sso backend.
In another window (leaving sso running) change directory to go into the 'sittercity' repo and run:
a) mkdir log
b) be rake db:setup
You should see all of the migrations run on the empire DB. If you see any errors then stop and go to the troubleshooting section at the bottom of this document.
5) Open a new terminal window (or another tmux window, doesn't matter) and log into your service-host VM. Run the following command:
'sudo vi /etc/haproxy/haproxy.cfg'
I have created another gist that contains my current file: https://gist.github.com/ptrimble/5623dc9aad55fcb797bc
You will need to edit this file by adding the lines referring to 'local-dev-server'. Also make sure that your sso-related entires match mine (for example, use 'sso.lxc' for the sso-admin backend).
Once it is added you must run the following command:
'sudo service haproxy restart'.
6) On OSX (not the VM) edit your /etc/hosts file to add the following line:
192.168.33.10 sso-admin.dev
Mine looks like this:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
192.168.33.10 sso-admin.dev
-----------
Now! Those were all one-time steps. You won't have to do those again.
Here are the steps that you must run each time you want to develop. The order matters!
1) Log into your VM and go to the ~/dev/sc-public-api directory. Launch it with 'binstubs/rackup -E production -p 9292'
2) In a separate window (tmux window or new terminal window), go to the ~/dev/marketplace-web directory and launch it with 'be pardrino start -p 8084'. You should not see any errors. If you do then see the troubleshooting section.
3) In a separate window (tmux window or new terminal window), ssh into the empire container ('ssh empire' inside of your VM) and go to the '/mnt/stormtrooper' directory, run 'bundle install' if necessary, and run the following command: 'be rake clonetrooper:dispatcher'. You must leave this running!
4) If everything is configured correctly then you should be able to go to '127.0.0.1' on OSX in your browser (doesn't matter which browser) and you should access the marketplace-web app that is running on your VM.
TROUBLESHOOTING
Problem: Everything is started without errors but I cannot access marketplace-web from OSX. I receive timeout errors.
Solution: Log into your VM and run 'sudo service haproxy restart'. Sometimes haproxy seems to freak out.
-----
Problem: When running step 4 in the one-time setup I receive errors running 'be rake db:setup' in sittercity.
Solution: Do you have your sso app running on the empire container? You might see sso-related errors if the answer is 'no'.
If you receive DB-related errors then on the empire container log into myself with just 'mysql' on the command line and running the following commands (NOTE - this will drop all empire data on your VM!):
1) mysql> drop database empire;
2) mysql> create database empire;
Then log off from mysql and run the command again. This will reseed the empire database with the appropriate initial values.
-------
Problem: You experience an error related to the 'pg' gem.
Solution: Run 'sudo apt-get install libpq-dev' from the terminal in your VM and rerun the command that caused the error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment