-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathstart_server
66 lines (56 loc) · 3.11 KB
/
start_server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
cd /home/ubuntu
# CHANGE THIS PREFIX TO YOUR PARAMETER STORE PREFIX!!!!!!!!!
# CHANGE THIS PREFIX TO YOUR PARAMETER STORE PREFIX!!!!!!!!!
# CHANGE THIS PREFIX TO YOUR PARAMETER STORE PREFIX!!!!!!!!!
# CHANGE THIS PREFIX TO YOUR PARAMETER STORE PREFIX!!!!!!!!!
# We're doing everything by path (i.e. glob) so make sure you have
# the slash at the beginning and end of the prefix!
PARAMETER_STORE_PREFIX="/DONATE_ANYTHING/"
# Storing all secrets in a .env.json file in the root directory. I've implemented
# a wrapper around django-environ to read in JSON files as well in config/settings/base.py
# -------------------------------------------------------------------------------------
# Grabbing our environment variables from Parameter Store and storing it in a JSON file
echo $(aws ssm get-parameters-by-path --with-decryption --region us-east-2 \
--path "${PARAMETER_STORE_PREFIX}") > /home/ubuntu/.env.json
# -------------------------------------------------------------------------------------
# This is Django/Flask/FastAPI specific. This is where you'll need to replace
# things if you're not using Django or if you're using an async framework (i.e. using
# websockets, long polling, etc.).
source venv/bin/activate
export DJANGO_SETTINGS_MODULE="config.settings.production"
# Single server running both celery and web server
# -------------------------------------------------------------------------------------
### If you want Celery using detached mode (if you want to add more nodes, then you'll
### need to run with supervisor. That's not something I want to set up here right now
### since it's more advisable to just have a separate autoscaling group with a different
### script):
# celery -A config.celery_app multi start worker -B -l info
# The following is Django oriented where I'm starting my HTTP server. If you're using a
# different web framework, understand that my port is on 5000 so that NGINX, the reverse
# proxy, can handle all the requests.
# How many workers? https://docs.gunicorn.org/en/stable/design.html#how-many-workers
gunicorn config.wsgi --bind 0.0.0.0:5000 --daemon
# -------------------------------------------------------------------------------------
# Multiple servers, one deployment group for Celery and another for Django
# NOTE: If you can, make three groups: one specifically to run ONE instance of celery
# beat, another for all celery workers, and another for our web servers.
# -------------------------------------------------------------------------------------
### This portion assumes you made two Autoscaling groups
# if ["$DEPLOYMENT_GROUP_NAME" == "project-Celery"]
# then
# celery -A config.celery_app worker -B -l info
# else
# gunicorn config.wsgi --bind 0.0.0.0:5000
# fi
### This portion assumes you made three Autoscaling groups
# if ["$DEPLOYMENT_GROUP_NAME" == "project-CeleryBeat"]
# then
# celery -A config.celery_app beat -l info
# elif ["$DEPLOYMENT_GROUP_NAME" == "project-CeleryWorker"]
# then
# celery -A config.celery_app worker -l info
# else
# gunicorn config.wsgi --bind 0.0.0.0:5000
# fi
# -------------------------------------------------------------------------------------