Skip to content

Commit

Permalink
database file (sqlite) moved to ../ + git version + deploy.sh script …
Browse files Browse the repository at this point in the history
…+ maintenance + clean
  • Loading branch information
Nodraak committed Oct 28, 2014
1 parent 6790a61 commit 4c49257
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 35 deletions.
2 changes: 1 addition & 1 deletion cdc.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ todo long run
- flake8 compliant (pep8 + other stuff)

to do now
- log : for each page, log : ip, date, page ??
- https://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/
- htaccess ? (index follow)
- previsualisation des posts
- news / tuto / articles : export pdf (pandoc)
- syndication (rss + atom) : https://docs.djangoproject.com/en/dev/ref/contrib/syndication/
Expand Down
39 changes: 39 additions & 0 deletions iTeam/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Adrien Chardon
# @Date: 2014-10-28 11:31:30
# @Last Modified by: Adrien Chardon
# @Last Modified time: 2014-10-28 11:36:55

# This file is part of iTeam.org.
# Copyright (C) 2014 Adrien Chardon (Nodraak).
#
# iTeam.org is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iTeam.org is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with iTeam.org. If not, see <http://www.gnu.org/licenses/>.


def git_version(request):
"""
Return the current deployed git version.
If not running on a production machine (if the 'git_version.txt' file is
not found), this will just display that the running version is local.
"""

try:
with open('git_version.txt') as f:
v = f.read().strip()
except IOError:
v = 'local_version'

return {'git_version': v}
21 changes: 3 additions & 18 deletions iTeam/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# @Author: Adrien Chardon
# @Date: 2014-09-02 12:01:06
# @Last Modified by: Adrien Chardon
# @Last Modified time: 2014-10-27 13:02:07
# @Last Modified time: 2014-10-28 11:33:49

# This file is part of iTeam.org.
# Copyright (C) 2014 Adrien Chardon (Nodraak).
Expand Down Expand Up @@ -150,7 +150,6 @@
'django.contrib.staticfiles',

'email_obfuscator',
# 'social.apps.django_app.default',
)

MIDDLEWARE_CLASSES = (
Expand All @@ -177,24 +176,10 @@
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',

# 'social.apps.django_app.context_processors.backends',
# 'social.apps.django_app.context_processors.login_redirect',
# Custom context processors
'iTeam.context_processors.git_version',
)

"""
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'social.backends.facebook.FacebookOAuth2',
)
"""

"""
FILE_UPLOAD_HANDLERS = (
"django.core.files.uploadhandler.MemoryFileUploadHandler",
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
)
"""

############################################
# Database + Cache
Expand Down
32 changes: 20 additions & 12 deletions prod/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ fi
cd /opt/iteam-env/iteam-site/

# Maintenance mode
#sudo rm /etc/nginx/sites-enabled/iteam
#sudo ln -s /etc/nginx/sites-available/iteam-maintenance /etc/nginx/sites-enabled/iteam-maintenance
#sudo service nginx reload
sudo rm /etc/nginx/sites-enabled/iteam
sudo ln -s /etc/nginx/sites-available/iteam-maintenance /etc/nginx/sites-enabled/iteam-maintenance
sudo service nginx reload

# Delete old branch if exists
# Retrieve prod branch
git branch prod origin/prod
git checkout prod
# Delete old branch if exists
git branch -D $1
# Switch to new tag
# Switch to new tag (Server has git < 1.9, git fetch --tags doesn't retrieve commits...)
git fetch --tags
# Server has git < 1.9, git fetch --tags doesn't retrieve commits...
git fetch
# Checkout the tag
git checkout $1
Expand All @@ -39,17 +39,25 @@ python manage.py collectstatic --noinput
# Update application data
source ../bin/activate
pip install --upgrade -r requirements.txt
python manage.py migrate
#python manage.py migrate
deactivate

# Restart iteam
sudo supervisorctl restart iteam

# Exit maintenance mode
#sudo rm /etc/nginx/sites-enabled/iteam-maintenance
#sudo ln -s /etc/nginx/sites-available/iteam /etc/nginx/sites-enabled/iteam
#sudo service nginx reload
sudo rm /etc/nginx/sites-enabled/iteam-maintenance
sudo ln -s /etc/nginx/sites-available/iteam /etc/nginx/sites-enabled/iteam
sudo service nginx reload

# Display current branch and commit
git status
echo "Commit deployé : `git rev-parse HEAD`"
DEPLOYED_HASH=$(git show-ref --tags | grep v1.0-RC1.1 | cut -d " " -f 1)
DEPLOYED_TAG=$(git show-ref --tags | grep v1.0-RC1.1 | cut -d " " -f 2 | cut -d "/" -f 3)
HEAD_HASH=$(git rev-parse HEAD)

echo "$DEPLOYED_TAG" > git_version.txt

echo "Commit deployé :"
echo "tag\t$DEPLOYED_TAG"
echo "hash\t$DEPLOYED_HASH"
echo "head\t$HEAD_HASH"
2 changes: 1 addition & 1 deletion prod/nginx-maintenance.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ server {
# media and static files

location /static/ {
alias /opt/iteam-env/iteam_static/;
alias /opt/iteam-env/static/;
expires 1d;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
Expand Down
6 changes: 6 additions & 0 deletions prod/settings_prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@
('images', os.path.join(SITE_ROOT, 'assets', 'images')),
)

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(SITE_ROOT, 'db.sqlite3'),
}
}
6 changes: 3 additions & 3 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,17 @@
<footer class="row">
<div class="large-6 columns">
<p>
iTeam 2014 - <a href="https://github.com/Nodraak/iteam-site">Open source</a>
iTeam 2014 - <a href="https://github.com/Nodraak/iteam-site">Open source ({{ git_version }})</a>
</p>
</div>
<div class="large-6 columns hide-for-medium hide-for-large hide-for-xlarge hide-for-xxlarge">
<ul class="inline-list left">
{% include "footer.html" %}
{% include "footer.part.html" %}
</ul>
</div>
<div class="large-6 columns hide-for-small">
<ul class="inline-list right">
{% include "footer.html" %}
{% include "footer.part.html" %}
</ul>
</div>
</footer>
Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions templates/pages/apropos.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ <h5>Javascript</h5>
</ul>
</div>
</div>
<div class="row">
<h3>Droits</h3>
<p>
ITeam.org est un site donc le code source est sous licence <a href="https://github.com/Nodraak/iteam-site/blob/prod/LICENSE">GNU GPL Affero version 3</a>, et provient en partie de <a href="http://progdupeu.pl">progdupeu.pl</a> et <a href="http://zestedesavoir.com">zestedesavoir.com</a>.
</p>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 4c49257

Please sign in to comment.