backend-management
v0.0.106
Published
Squadle Backend Management
Downloads
9
Readme
Backend-Management
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.
Requirements
- git (https://www.atlassian.com/git/tutorials/install-git)
- Node.js v16
- npm v8/9
How do I get set up?
To do development and run a local copy of backend-mangagement:
Get a copy from bitbucket
git clone [email protected]:Squadle/backend-management.git
or
git clone https://[email protected]/Squadle/backend-management.git
Install Modules
npm install
How do I start up the api server?
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
How do I run one of the commandline scripts?
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'
Where is Backend-Management used?
| 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 |
What other Squadle Libraries does Backend-Management use?
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
How do I publish / save my changes to backend-management
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
How do I update each of the installations listed above?
Production Squad-Leader Servers
Make sure you have gcloud installed first
./gcp/update-backend-management.sh
Development Squad-Leader Server 1
Make sure you have gcloud installed first
./gcp/update-backend-management-staging1.sh
Development Squad-Leader Server 2
Make sure you have gcloud installed first
./gcp/update-backend-management-staging2.sh
Production Backend-Management-1
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
Production Heroku
Setup:
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://[email protected]/Squadle/backend-management.git (fetch)
# origin https://[email protected]/Squadle/backend-management.git (push)
To deploy to heroku:
# long way
git push heroku master
# shortcut
npm run heroku