parent
bae3ca28fa
commit
af66e4959f
7 changed files with 205 additions and 11 deletions
@ -0,0 +1,71 @@ |
|||||||
|
.PHONY: requirements requirements-upgrade freeze syncdb run run-public makemessages compilemessages collectstatic cloc clean user south |
||||||
|
|
||||||
|
project_name=proj
|
||||||
|
|
||||||
|
requirements: |
||||||
|
-@echo "### Installing requirements"
|
||||||
|
-@pip install -r requirements.txt
|
||||||
|
|
||||||
|
requirements-upgrade: |
||||||
|
-@echo "### Upgrading requirements"
|
||||||
|
-@pip freeze | cut -d = -f 1 | xargs pip install -U
|
||||||
|
|
||||||
|
freeze: |
||||||
|
-@echo "### Freezing python packages to requirements.txt"
|
||||||
|
-@pip freeze > requirements.txt
|
||||||
|
|
||||||
|
syncdb: |
||||||
|
-@echo "### Creating database tables and loading fixtures"
|
||||||
|
@PYTHONPATH=$(PYTHONPATH):. DJANGO_SETTINGS_MODULE=$(project_name).settings ipython manage.py syncdb --noinput
|
||||||
|
@PYTHONPATH=$(PYTHONPATH):. DJANGO_SETTINGS_MODULE=$(project_name).settings ipython manage.py migrate
|
||||||
|
|
||||||
|
run: |
||||||
|
@PYTHONPATH=$(PYTHONPATH):. DJANGO_SETTINGS_MODULE=$(project_name).settings ipython manage.py runserver
|
||||||
|
|
||||||
|
run-public: |
||||||
|
@PYTHONPATH=$(PYTHONPATH):. DJANGO_SETTINGS_MODULE=$(project_name).settings ipython manage.py runserver 0.0.0.0:8000
|
||||||
|
|
||||||
|
shell: |
||||||
|
@PYTHONPATH=$(PYTHONPATH):. DJANGO_SETTINGS_MODULE=$(project_name).settings python manage.py shell
|
||||||
|
|
||||||
|
solrrun: |
||||||
|
/opt/solr/bin/solr start -p 8983
|
||||||
|
|
||||||
|
solrstop: |
||||||
|
/opt/solr/bin/solr stop -all
|
||||||
|
|
||||||
|
makemessages: |
||||||
|
-@ipython manage.py makemessages --all
|
||||||
|
|
||||||
|
compilemessages: |
||||||
|
-@ipython manage.py compilemessages
|
||||||
|
|
||||||
|
collectstatic: |
||||||
|
@ipython manage.py collectstatic
|
||||||
|
|
||||||
|
user: |
||||||
|
-@ipython manage.py createsuperuser
|
||||||
|
|
||||||
|
# If the first argument is "south"...
|
||||||
|
ifeq (south,$(firstword $(MAKECMDGOALS))) |
||||||
|
# use the rest as arguments for "south"
|
||||||
|
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
||||||
|
# ...and turn them into do-nothing targets
|
||||||
|
$(eval $(RUN_ARGS):;@:)
|
||||||
|
endif |
||||||
|
south: |
||||||
|
-@python manage.py schemamigration $(RUN_ARGS) --auto
|
||||||
|
-@python manage.py migrate $(RUN_ARGS)
|
||||||
|
|
||||||
|
cloc: |
||||||
|
-@echo "### Counting lines of code within the project"
|
||||||
|
-@echo "# Total:" ; find . -iregex '.*\.py\|.*\.js\|.*\.html\|.*\.css' -type f -exec cat {} + | wc -l
|
||||||
|
-@echo "# Python:" ; find . -name '*.py' -type f -exec cat {} + | wc -l
|
||||||
|
-@echo "# JavaScript:" ; find . -name '*.js' -type f -exec cat {} + | wc -l
|
||||||
|
-@echo "# HTML:" ; find . -name '*.html' -type f -exec cat {} + | wc -l
|
||||||
|
-@echo "# CSS:" ; find . -name '*.css' -type f -exec cat {} + | wc -l
|
||||||
|
|
||||||
|
clean: |
||||||
|
-@echo "### Cleaning *.pyc and .DS_Store files "
|
||||||
|
-@find . -name '*.pyc' -exec rm -f {} \;
|
||||||
|
-@find . -name '.DS_Store' -exec rm -f {} \;
|
||||||
@ -0,0 +1,118 @@ |
|||||||
|
# -*- coding: utf-8 -*- |
||||||
|
from os.path import join, basename |
||||||
|
from collections import namedtuple |
||||||
|
|
||||||
|
from fabric.api import * |
||||||
|
|
||||||
|
env.roledefs = { |
||||||
|
'dev': ['root@176.121.11.165'], |
||||||
|
'prod': ['root@176.121.11.162'], |
||||||
|
} |
||||||
|
env.passwords = { |
||||||
|
'root@176.121.11.165:22': 'ue6R287QZfMc', |
||||||
|
'root@176.121.11.162:22': 'XcS2jx5e8k6n', |
||||||
|
} |
||||||
|
|
||||||
|
REMOTE_HOME_DIR = '/home/www/expomap/' |
||||||
|
LOCAL_HOME_DIR = '/home/alexander/projects/expomap/' |
||||||
|
|
||||||
|
nginx_conf = '/etc/nginx/sites-available/hit.expomap.ru' |
||||||
|
apache2_conf = '/etc/apache2/sites-available/proj.com' |
||||||
|
settings_conf = join(REMOTE_HOME_DIR, 'proj/settings.py') |
||||||
|
services = ['nginx', 'apache2'] |
||||||
|
|
||||||
|
|
||||||
|
def set_host(host): |
||||||
|
env.hosts = env.roledefs.get(host) |
||||||
|
env.role = host |
||||||
|
|
||||||
|
|
||||||
|
def dev(): |
||||||
|
set_host('dev') |
||||||
|
|
||||||
|
|
||||||
|
def prod(): |
||||||
|
set_host('prod') |
||||||
|
|
||||||
|
|
||||||
|
def get_configs(): |
||||||
|
localdir = join(LOCAL_HOME_DIR, 'support/', env.role) |
||||||
|
get(nginx_conf, localdir) |
||||||
|
get(apache2_conf, localdir) |
||||||
|
get(join(REMOTE_HOME_DIR, 'schema.xml'), localdir) |
||||||
|
get(settings_conf, localdir) |
||||||
|
|
||||||
|
|
||||||
|
def put_configs(): |
||||||
|
localdir = join(LOCAL_HOME_DIR, 'support/', env.role) |
||||||
|
# nginx |
||||||
|
put(join(localdir, basename(nginx_conf)), |
||||||
|
nginx_conf) |
||||||
|
# apache2 |
||||||
|
put(join(localdir, basename(apache2_conf)), |
||||||
|
apache2_conf) |
||||||
|
# settings |
||||||
|
put(join(localdir, basename(settings_conf)), |
||||||
|
settings_conf) |
||||||
|
|
||||||
|
|
||||||
|
def call_state(state, only=None): |
||||||
|
if only is not None and only in services: |
||||||
|
run('service {only} {state}'.format(only=only, state=state)) |
||||||
|
return |
||||||
|
for service in services: |
||||||
|
run('service {service} {state}'.format(service=service, state=state)) |
||||||
|
|
||||||
|
def put_1345(): |
||||||
|
call_state('stop', only='nginx') |
||||||
|
with cd(REMOTE_HOME_DIR): |
||||||
|
run('git pull') |
||||||
|
# put_configs() |
||||||
|
call_state('start', only='nginx') |
||||||
|
|
||||||
|
|
||||||
|
def chown(): |
||||||
|
with cd(REMOTE_HOME_DIR): |
||||||
|
run('chown -Rv www-data:www-data .') |
||||||
|
|
||||||
|
|
||||||
|
def pull(): |
||||||
|
with cd(REMOTE_HOME_DIR): |
||||||
|
call_state('stop', only='apache2') |
||||||
|
run('git pull') |
||||||
|
call_state('start', only='apache2') |
||||||
|
|
||||||
|
|
||||||
|
def stage3_pre_final(): |
||||||
|
with cd(REMOTE_HOME_DIR): |
||||||
|
run('pip install pandas') |
||||||
|
run('pip install django-rosetta==0.7.6') |
||||||
|
run('git checkout master') |
||||||
|
run('git pull') |
||||||
|
call_state('stop') |
||||||
|
put_configs() |
||||||
|
run('python manage.py migrate conference 0001 --fake') |
||||||
|
run('python manage.py migrate conference') |
||||||
|
run('python manage.py migrate expobanner') |
||||||
|
run('python manage.py migrate theme 0001 --fake') |
||||||
|
run('python manage.py migrate theme 0002') |
||||||
|
run('python manage.py migrate article 0001 --fake') |
||||||
|
run('python manage.py migrate article 0002') |
||||||
|
run('python manage.py migrate stats_collector') |
||||||
|
run('python manage.py crontab remove') |
||||||
|
run('python manage.py crontab add') |
||||||
|
chown() |
||||||
|
call_state('start') |
||||||
|
|
||||||
|
|
||||||
|
def stage3_release(): |
||||||
|
call_state('stop') |
||||||
|
with cd(REMOTE_HOME_DIR): |
||||||
|
# run('python manage.py themeblog_to_blog') |
||||||
|
run('git checkout stage3_release') |
||||||
|
run('git pull') |
||||||
|
run('python manage.py migrate settings 0002 --fake') |
||||||
|
run('python manage.py migrate settings') |
||||||
|
run('python manage.py migrate article 0003') |
||||||
|
chown() |
||||||
|
call_state('start') |
||||||
Loading…
Reference in new issue