Backend-Management is a series of command-line tools and API web server. It leverages several Squadle libraries in over to create servies and tools that are used to run backend processing and to support our Web Portal and mobile applications. The majority of code is written in Coffeescript with some additional Bash Shell scripts.
- git (https://www.atlassian.com/git/tutorials/install-git)
- Node.js v16
- npm v8/9
To do development and run a local copy of backend-mangagement:
git clone git@bitbucket.org:Squadle/backend-management.git
or
git clone https://BITBUCKET_USERNAME@bitbucket.org/Squadle/backend-management.git
npm install
The server is not required to run the command line scripts. The server is use by the web portal (hq.squadle.com) and the mobile applications (Checklist, Workflow, Manager's App) and many of the backend services that run in GCP.
You can start the server in one of two modes, pointing to the Production database or the Development Database
# For Production
coffee server.coffee --production
# For Development
coffee server.coffee --development
There are over 225 command line coffeescript applications in backend-management. Almost all of them have a command line argument interface, which means you can always run any of the coffeescript script with '--help****' and it will show you all the available options for the script.
For Example, to generate a daily email for a specific user:
coffee src/generateDailyEmail.coffee --production --user='-KgLCub0zw5DMP0-Ykdz'
Platform | Environment | Project | Additional Info. | What is it used for? |
---|---|---|---|---|
GCP | Production | squad-leader | 2 VMs in an instance group | API for production applications |
GCP | Development | squad-leader | 1 VM in an instance group | API for development to support hq.staging.squadle.com |
GCP | Development | squad-leader | 1 VM in an instance group | API for development to support hq.staging2.squadle.com |
GCP | Production | firebase-squadle | 1 VM called 'backend-management-1' | VM where cron jobs and manual execution of backend-management is performed |
Heroku | Production | backend-management | No dyno | The majority of cron jobs that keep the platform running |
Backend-Management makes significant use of two Squadle libraries: squadle-lib-command and squadle-lib-nodejs
General development practise is you should always run the latest version of these libraries. To make sure you are always up to date with the latest Squadle (and third-party) libraries. Perform the following command often:
npm run update
Backend-management is a regular git repository, you can push your changes into a branch (master or feature-branch) with standard git commands or use the short-cuts (that increment the package version, commit local changes and push to the repo).
Shortcut:
npm run pub
Make sure you have gcloud installed first
./gcp/update-backend-management.sh
Make sure you have gcloud installed first
./gcp/update-backend-management-staging1.sh
Make sure you have gcloud installed first
./gcp/update-backend-management-staging2.sh
ssh to the server via the gcp-console or use gcloud compute ssh --project firebase-squadle backend-management-1
# login as root
sudo su -
# Change directory to backand-management base
cd /root/backend-mangement
# Get latest from repo
git pull
# Install any modules
npm install
You must have the Heroku cli installed and have a Heroku account.
For macos: brew tap heroku/brew && brew install heroku
From your laptop, make sure you are logged into Heroku from the command line.
heroku login
Do a one time setup, where you attach your local repo to heroku for deployment
# Change directory to your location copy of backend-management
cd backend-management
# Create a remote connection between your local copy and heroku servers
heroku git:remote -a backend-management
# Validate the remote connection has been created
git remote --verbose
# you should see something like:
# heroku https://git.heroku.com/backend-management.git (fetch)
# heroku https://git.heroku.com/backend-management.git (push)
# origin https://jehangirjungalwala@bitbucket.org/Squadle/backend-management.git (fetch)
# origin https://jehangirjungalwala@bitbucket.org/Squadle/backend-management.git (push)
# long way
git push heroku master
# shortcut
npm run heroku