In case anyone reads this, this guide is mainly for my reference during development.
In the root project directory, you can run:
npm install --prefix clientNext, you can change to the 'client' directory and run:
npm startTo kill all PID's in client directory run:
sudo lsof -ti:4000 | xargs sudo kill -9From the chit-chat project directory run:
pip install -r requirements.txtCheck if dependencies are outdated:
pip list --outdatedUpgrade dependencies with:
pip install --upgrade package-nameUninstall dependencies with:
pip uninstall package-nameChange to the server directory: Check if the PostgreSQL server is online by running:
sudo service postgresql statusIf it's offline, start the server with:
sudo service postgresql startSet up/create environment variables, largely for endpoints:
Set environment variables to development:
source set_env_vars.sh developmentSet environment variables to production:
source set_env_vars.sh productionCheck PostgreSQL database connection:
Change into the 'server directory' then
python test_db_connection.pyTest password hashing:
python test_password_hashing.pyThe alembic directory and alembic.ini file should be in the server directory. In the env.py file, change the import from import server.models as models to import models as models. Next generate alembic.ini file if needed using script, make sure this alembic.ini is in .gitignore. Run migratiions and check if they run correctly using psql. May have to manually do it using psql commands.
For production development, the alembic directory and alembic.ini file should be in the root project directory. Alembic.ini can be generated using script, does not need to be hidden in .gitignore as no sensitive information is in it. Change import in env.py file to import server.models as models. Run migrations using heroku commands, doing it manually if needed as well.
Navigate to 'server' directory:
For local database migrations:
python localdb_generate_alembic_ini.pyFor heroku database migrations:
python heroku_generate_alembic_ini.pyRun migrations:
Locally:
alembic revision --autogenerate -m "Your migration message here"alembic upgrade headWith Heroku:
heroku run alembic upgrade head --app chit-chat-backendCheck Heroku database:
heroku pg:psql --app chit-chat-backendEnter postgres shell:
```bash
sudo -u postgres psql
```
Check database and roles:
```bash
\du
\l
```
Check users table:
```bash
SELECT table_name FROM information_schema.tables WHERE table_name = 'users';
```
List tables:
```bash
psql -U db-username -d db-name -h localhost -W
```
Enter password for db-username, then:
```bash
\dt
```
Spin up the backend server in the 'chit-chat' directory with:
gunicorn -w 4 -b 0.0.0.0:5555 server.app:appIf it won't spin up, see if it's already running with:
pgrep gunicornKill these PIDs with:
pkill -9 gunicornThen re-run the gunicorn command:
gunicorn -w 4 -b 0.0.0.0:5555 server.app:appCheck heroku logs:
heroku logs --tail --app chit-chat-backendScale/run dyno:
heroku ps:scale web=1 --app chit-chat-backendStop dyno
heroku ps:scale web=0 --app chit-chat-backendRestart dyno:
heroku ps:restart --app chit-chat-backendexport PATH="/usr/local/bin:$HOME/Development/code/bag-talk/chit-chat:$PATH"