### dev-microservices-setup

Tools to help developers run a set of collaborating microservices locally for
testing and debugging.

### Setup

See [doc/setup.md](doc/setup.md)

### Usage

After setup, run `owsdev --help` to see a list of commands.

See [doc/running.md](doc/running.md) for starting/stoping info.

### How it works

* Remap qa-ows-*.theorchard.io to localhost.
* Proxy requests based on hostname to services running locally on specific ports.
* Services are configured to all use same db, same local redis, same local dynamodb
* ...
* Profit!


### Adding a service

* Services are specified in owsdev/data/services.json. 
* Environment variables can use template strings.
* Replacement values are defined in owsdev.service

### Using PyCharm debugger

Sometimes, you may want to run a particular microservice in a debugger. 

1. Open the project in pycharm. 
1. Create a run config for dev.py. 
1. Set environment variables
using the output of `owsdev print_env <service-name>`. 
1. Kill the service in tmux by
focusing on the pane and `Ctrl-C`. 
1. Run the debug config and do whatever.

### A few useful tmux commands

* `Ctrl-B D` to detach
* `Ctrl-B Q <num>` to jump to a particular pane
* `Ctrl-B <arrow>` to navigate around panes

### Future enhancements

* Better error message when config file not found.
* Use doctor to check for requirements, presence of directories, status of services and support applications.
* Eliminate need for build dir (only used for generating hosts file, could be remade every time instead)
* Generate config file rather than require copy + modify
* Allow basedir use in config file, have sensible defaults.
* Set default values in config:
	* split grass: user_id
	* dynamodblocal port / access_key_id / secret_access_key / data_dir / log_dir
	* redis port and host
* Install dynamodb local from command line rather than curl, etc.
* Clean install and setup python projects.
* Don't require proxy window, ideally don't require sudo (much)
* Target to list variables for service declarations
* Move service declaration into each repo as opposed to central one.
* Die if tmux session already running
* Move hosts.base into user-owned location.
* Make some constants for various things
* Allow proxy to running background, use owsdev commands to start/stop
* make work with grass services that work over https
