Files
old-holivud2/README.md

168 lines
4.4 KiB
Markdown
Raw Normal View History

2020-05-31 22:38:19 +02:00
### Setup
Install RVM to manage ruby version:
```bash
\curl -sSL https://get.rvm.io | bash
rvm install 2.6.3
```
Install external dependencies:
#### For MacOS:
```bash
brew tap heroku/brew && brew install heroku
brew install postgres
brew install redis
brew install ffmpeg
brew install yarn
```
#### For Linux (Ubuntu):
```bash
curl https://cli-assets.heroku.com/install.sh | sh
sudo apt-get install postgresql postgresql-contrib
sudo apt-get install redis-server
sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get install ffmpeg
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update
sudo apt-get install yarn
```
Then run:
```bash
bin/setup
```
to create your databases
You will need to:
- Get environment variables from fellow teammates to populate into `.env` (See env.sample for examples)
- AWS account to have access to S3 buckets
- Heroku account to deploy
- Set DOMAIN and WEB_PORT variables - otherwise application won't work properly. Use DOMAIN=localhost and WEB_PORT=3000 for the default values
- Set ZOOM_API_KEY and ZOOM_API_SECRET to integrate with Zoom.us for automatic meeting creation.
After filling up the .env with correct values
Run setup again:
```bash
bin/setup
```
### Running tests
```bash
rspec
yarn test
```
### Running Data migrations
```bash
rails data:migrate
```
### Current deployment pipeline on Heroku
- Review -> Staging |-> Production
|-> Demo
#### Working with environments using Parity
[Parity](https://github.com/thoughtbot/parity) provides Heroku command wrappers for each environment under the `bin` folder.
### Useful Heroku commands
##### Manually Deploying to Review
The Review environment is auto-deployed from GitHub `master`. But if you need to manually deploy:
```bash
bin/review deploy
```
##### Running migrations manually (should be done automatically by Heroku via Procfile)
```bash
bin/review run db:migrate
```
##### Rails console into Review environment
```bash
bin/review console
```
##### We keep locale files sorted in alphabetical order. This can be done programmatically
```
rake i18n:sort
```
## Zoom.us integration
DirectMe app offers live broadcasting. Users are offered to paralelly connect to the Zoom meeting to have a video conference while the streaming happens. In order to use the Zoom functionality, the app needs to have the API keys provided. You need Zoom PRO account for this feature.
#### Zoom.us api keys
1. Log in to you zoom.us account
2. Go to https://marketplace.zoom.us/develop/create
3. Choose JWT application
4. Copy API Key and API Secret
## Working Locally
#### Polling for analysis status updates
When videos are uploaded, a video/audio analysis process is initiated. Typically the analysis process sends an SNS notification when it is completed. Those SNS notifications hit a webhook URL within the app to update the status accordingly. This requires a public URL, which you likely won't have in development.
As an alternative, we can poll for status updates using the following Rake task.
```bash
rake dev:poll_for_analysis_updates
```
To run this continuously, there is a [Clockwork](https://github.com/adamwiggins/clockwork) scheduler included.
```bash
bin/clockwork lib/dev_clockwork.rb
```
#### Running a real async background queue locally
1. Verify redis has been installed
1. Set REDIS_URL in your `.env` file
```bash
REDIS_URL=redis://127.0.0.1:6379
```
1. Start Sidekiq
```bash
bundle exec sidekiq -q default -q mailers -c 5
```
### Setup pairing script
[Check out the repo here](https://github.com/pivotal-legacy/git_scripts)
- Tool to add two or more authors on a commit message quickly
- Make sure to add yourself or new devs to the `.pairs` file in the repo
`cd /usr/local/bin && curl -L http://github.com/pivotal/git_scripts/tarball/master | gunzip | tar xvf - --strip=2`
then `git pair XX` where XX are your initials from the pairs file
Enjoy!
## Problems with setting up environment
### Database setup
If the setup fails in the point after at least one of the databases
have been set up.
1. Drop the databases
```bash
rails db:drop
```
1. Run the setup again.
## Optional helpers
# Run rubocop fix script as a pre-commit git hook
Add following as .git/hooks/pre-commit file
```
#!/bin/sh
exec ./bin/rubocopfix.sh
```