-
Notifications
You must be signed in to change notification settings - Fork 4
/
manual_deployment.txt
executable file
·105 lines (80 loc) · 2.81 KB
/
manual_deployment.txt
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
MANUAL DEPLOYMENT
Target: Linux 3.13.0-34-generic #60-Ubuntu SMP x86_64 GNU/Linux
Main sources:
https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
http://stackoverflow.com/questions/23073829/uwsgi-wont-reload-restart-or-let-me-run-service
sudo aptitude install python-pip libpq-dev python-dev git nginx python-virtualenv tmux postgresql postgresql-contrib uwsgi-plugin-python
sudo pip install uwsgi
mkdir ~/radar
touch ~/radar/radar_nginx.conf
touch ~/radar/uwsgi_params
touch ~/radar/radar_uwsgi.ini
sudo ln -s ~/radar/radar_nginx.conf /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
cd ~/radar
virtualenv --no-site-packages venv_radar
source venv_radar/bin/activate
git clone https://github.com/leonardofl/radar_parlamentar.git repo
cd repo
easy_install -U distribute
pip install -r requirements.txt
pip install ipython
mkdir /tmp/django_cache
sudo chmod 666 -R /tmp/django_cache/
sudo su - postgres
createdb radar
createuser radar -P
psql
GRANT ALL PRIVILEGES ON DATABASE mydb TO myuser;
echo "localhost:5432:radar:radar:$SENHA" > ~/.pgpass
chmod 600 .pgpass
cd ~/radar/repo/radar_parlamentar/settings
<create settings/production.py>
cd ~/radar/repo/radar_parlamentar
python manage.py syncdb
python manage.py migrate
export LANG="en_US.UTF-8" # avoids a django bug. not necessary if $LANG is already set
python manage.py createsuperuser (admin / password)
#add root user to nginx’s group (www-data), or vice-versa,
#so that nginx can read and write to the socket properly
sudo usermod -a -G root www-data
sudo usermod -a -G www-data root
#obs: "usermod -a -G ftp tony" adds tony user to ftp group
# importing radar data
cd ~/radar/repo/radar_parlamentar
python manage.py shell
from importadores import cmsp
cmsp.main()
from importadores import senado
senado.main()
from importadores import camara
camara.main()
# configuring uwsgi to start at boot
sudo mkdir -p /var/log/uwsgi
touch /etc/init/uwsgi.conf
sudo initctl start uwsgi
#(sudo restart uwsgi)
sudo /etc/init.d/nginx restart
echo "" >> .bashrc
echo "#Radar section" >> .profile
echo "export RADAR_HOME=\$HOME/radar/repo/radar_parlamentar" >> .profile
echo "source \$RADAR_HOME/settings/is_prod.sh" >> .profile
echo "export PATH=\$PATH:\$RADAR_HOME/cron" >> .profile
echo "source \$HOME/radar/venv_radar/bin/activate" >> .profile
crontab $RADAR_HOME/cron/crontab
sudo mkdir /var/log/radar
sudo chown $USER /var/log/radar
****
#Updating
git pull
sudo restart uwsgi
clear-cache.sh
***
Using manage.py:
source venv_radar/bin/activate # activate virtual env if it is not already activated
python manage.py ... # whatever
Exploring the database:
psql radar radar -h localhost
show tables: \dt
show table schema: \d <table_name>