So while I am developing I have two firestore emulators spun up on separate ports.
Emulator 1 - testing firestore server rules:
On localhost:9090 I have the emulator that I use exclusively for testing my server rules. My server rule test are run automatically on file save of firestore.rules . Every test function of my firestore rules clears out the firestore database at localhost:9090 upon completion. So if there are N test of firestore rules than I clear out the database at localhost:9090 N times before getting the test results. Simple enough.
Emulator 2 - persistent database for interactive development:
On localhost:9095 I have the emulator that I use as I am developing a feature. It is usually only cleared (manually) by me between development of a feature. I also run the emulator UI on this one so that I can view/edit the data with the web-ui as I am working.
ASK:
I currently spin up separate emulators in separate windows using `firebase emulators:start`, they each read their local firebase.json file in start up appropriately. I am wondering if it is possible to use a single emulator with different ports pointing to different instances of the firestore database though? To be clear, same security rules, but isolated databases that can be cleared for different reasons independently.
Minor 1:
Upon starting the second emulator, I usually get this little message
```
emulators: Starting emulators: firestore
⚠ hub: emulator hub unable to start on port 4400, starting on 4401 instead.
i firestore: Firestore Emulator logging to firestore-debug.log
┌──────────────────────────────────────────────────────────────┐
│ ✔ All emulators ready! It is now safe to connect your apps. │
└──────────────────────────────────────────────────────────────┘
┌───────────┬────────────────┐
│ Emulator │ Host:Port │
├───────────┼────────────────┤
│ Firestore │ localhost:8095 │
└───────────┴────────────────┘
Other reserved ports: 4401
```
Does not seem to make a huge difference, not sure what the hub thing is about.
Minor 2:
I think this may be unrelated to running multiple emulators, but sometimes the emulator(s) does not die properly. I have to `kill ` them manually after pressing Ctrl-C. My machine:
```
➜ ~ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
```