From 5e849936de343b56799102042aed0744810aa1ae Mon Sep 17 00:00:00 2001 From: Flavio Amieiro Date: Mon, 3 Dec 2012 13:31:46 -0200 Subject: [PATCH 1/3] Adapts configuration files to the new repository structure --- server_config/nginx.conf | 2 +- server_config/pypln-broker.conf | 2 +- server_config/pypln-pipeliner.conf | 2 +- server_config/pypln-router.conf | 2 +- server_config/pypln-web.conf | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/server_config/nginx.conf b/server_config/nginx.conf index 3ed0eea..60d7114 100644 --- a/server_config/nginx.conf +++ b/server_config/nginx.conf @@ -6,7 +6,7 @@ server { client_max_body_size 50M; location /site_media/static/ { - alias /srv/pypln/project/pypln/web/site_media/static_files/; + alias /srv/pypln/project/web/pypln/web/site_media/static_files/; } # http://docs.gunicorn.org/en/latest/deploy.html has more information about diff --git a/server_config/pypln-broker.conf b/server_config/pypln-broker.conf index e25a335..2a6d87d 100644 --- a/server_config/pypln-broker.conf +++ b/server_config/pypln-broker.conf @@ -1,5 +1,5 @@ [program:pypln-broker] -command=/srv/pypln/project/exec_in_virtualenv.sh pypln-broker +command=/srv/pypln/project/backend/exec_in_virtualenv.sh pypln-broker directory=/srv/pypln/project/ user=pypln stdout_logfile=/srv/pypln/logs/pypln-broker.out diff --git a/server_config/pypln-pipeliner.conf b/server_config/pypln-pipeliner.conf index 18922f8..f2ac048 100644 --- a/server_config/pypln-pipeliner.conf +++ b/server_config/pypln-pipeliner.conf @@ -1,5 +1,5 @@ [program:pypln-pipeliner] -command=/srv/pypln/project/exec_in_virtualenv.sh pypln-pipeliner +command=/srv/pypln/project/backend/exec_in_virtualenv.sh pypln-pipeliner directory=/srv/pypln/project/ user=pypln stdout_logfile=/srv/pypln/logs/pypln-pipeliner.out diff --git a/server_config/pypln-router.conf b/server_config/pypln-router.conf index 963a064..7677152 100644 --- a/server_config/pypln-router.conf +++ b/server_config/pypln-router.conf @@ -1,5 +1,5 @@ [program:pypln-router] -command=/srv/pypln/project/exec_in_virtualenv.sh pypln-router +command=/srv/pypln/project/backend/exec_in_virtualenv.sh pypln-router directory=/srv/pypln/project/ user=pypln stdout_logfile=/srv/pypln/logs/pypln-router.out diff --git a/server_config/pypln-web.conf b/server_config/pypln-web.conf index 79bfe3f..194a1e5 100644 --- a/server_config/pypln-web.conf +++ b/server_config/pypln-web.conf @@ -1,6 +1,6 @@ [program:pypln-web] -command=/srv/pypln/project/pypln/web/runwsgi.sh -directory=/srv/pypln/project/pypln/web/ +command=/srv/pypln/project/web/pypln/web/runwsgi.sh +directory=/srv/pypln/project/web/pypln/web/ user=pypln stdout_logfile=/srv/pypln/logs/pypln-web.out stderr_logfile=/srv/pypln/logs/pypln-web.err From bb8d456b618b57d6774301e42e90afbc8cbed997 Mon Sep 17 00:00:00 2001 From: Flavio Amieiro Date: Mon, 3 Dec 2012 19:08:27 -0200 Subject: [PATCH 2/3] Adjust fabfile to the new repository structure. --- fabfile.py | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/fabfile.py b/fabfile.py index 5734b47..ad54698 100644 --- a/fabfile.py +++ b/fabfile.py @@ -29,8 +29,11 @@ LOG_DIR = os.path.join(HOME, "logs/") BACKUP_DIR = os.path.join(HOME, "backups/") PROJECT_ROOT = os.path.join(HOME, "project/") -PROJECT_WEB_ROOT = os.path.join(PROJECT_ROOT, "pypln/web/") -REPO_URL = "https://github.com/NAMD/pypln.git" +PYPLN_BACKEND_ROOT = os.path.join(PROJECT_ROOT, "backend") +PYPLN_WEB_ROOT = os.path.join(PROJECT_ROOT, "web/") +DJANGO_PROJECT_ROOT = os.path.join(PYPLN_WEB_ROOT, "pypln/web/") +BACKEND_REPO_URL = "https://github.com/NAMD/pypln.backend.git" +WEB_REPO_URL = "https://github.com/NAMD/pypln.web.git" ACTIVATE_SCRIPT = os.path.join(PROJECT_ROOT, "bin/activate") def _reload_supervisord(): @@ -38,11 +41,16 @@ def _reload_supervisord(): sudo("service supervisor stop") sudo("service supervisor start") +def _update_repository(rev): + run("git remote update") + run("git checkout {}".format(rev)) + run("git reset --hard {}".format(rev)) + def _update_code(rev="master"): - with cd(PROJECT_ROOT): - run("git remote update") - run("git checkout {}".format(rev)) - run("git reset --hard {}".format(rev)) + with cd(PYPLN_BACKEND_ROOT): + _update_repository(rev) + with cd(PYPLN_WEB_ROOT): + _update_repository(rev) def create_db(db_user, db_name, db_host="localhost", db_port=5432): # we choose a random password with letters, numbers and some punctuation. @@ -113,12 +121,13 @@ def initial_setup(rev="master"): _create_secret_key_file() with settings(warn_only=True, user=USER): - run("git clone {} {}".format(REPO_URL, PROJECT_ROOT)) + run("git clone {} {}".format(WEB_REPO_URL, PYPLN_WEB_ROOT)) + run("git clone {} {}".format(BACKEND_REPO_URL, PYPLN_BACKEND_ROOT)) _update_code(rev) run("virtualenv --system-site-packages {}".format(PROJECT_ROOT)) for daemon in ["router", "pipeliner", "broker", "web"]: - config_file_path = os.path.join(PROJECT_ROOT, + config_file_path = os.path.join(PYPLN_BACKEND_ROOT, "server_config/pypln-{}.conf".format(daemon)) sudo("ln -sf {} /etc/supervisor/conf.d/".format(config_file_path)) @@ -134,7 +143,7 @@ def initial_setup(rev="master"): _reload_supervisord() - nginx_vhost_path = os.path.join(PROJECT_ROOT, "server_config/nginx.conf") + nginx_vhost_path = os.path.join(PYPLN_BACKEND_ROOT, "server_config/nginx.conf") sudo("ln -sf {} /etc/nginx/sites-enabled/pypln".format(nginx_vhost_path)) sudo("service nginx restart") @@ -143,12 +152,18 @@ def initial_setup(rev="master"): def deploy(rev="master"): with prefix("source {}".format(ACTIVATE_SCRIPT)), settings(user=USER), cd(PROJECT_ROOT): _update_code(rev) - run("python setup.py install") - run("python -m nltk.downloader all") + with cd(PYPLN_BACKEND_ROOT): + run("python setup.py install") + + with cd(PYPLN_WEB_ROOT): + run("python setup.py install") - with cd(PROJECT_WEB_ROOT): + #TODO: We need to put all pypln.web requirements in one place. + with cd(DJANGO_PROJECT_ROOT): run("pip install -r requirements/project.txt") + run("python -m nltk.downloader all") + manage("syncdb --noinput") manage("collectstatic --noinput") @@ -157,7 +172,7 @@ def deploy(rev="master"): def manage(command, environment="production"): # FIXME: we need to be in the web root because of path issues that should # be fixed - with prefix("source {}".format(ACTIVATE_SCRIPT)), cd(PROJECT_WEB_ROOT), settings(user=USER): - manage_script = os.path.join(PROJECT_WEB_ROOT, "manage.py") + with prefix("source {}".format(ACTIVATE_SCRIPT)), cd(DJANGO_PROJECT_ROOT), settings(user=USER): + manage_script = os.path.join(DJANGO_PROJECT_ROOT, "manage.py") run("python {} {} --settings=settings.{}".format(manage_script, command, environment)) From 2b2d8abe754064059c5ded9e4c21c75558f7e2b8 Mon Sep 17 00:00:00 2001 From: Flavio Amieiro Date: Tue, 4 Dec 2012 16:49:11 -0200 Subject: [PATCH 3/3] Turns pypln.backend into a namespace package http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages --- pypln/__init__.py | 2 ++ setup.py | 1 + 2 files changed, 3 insertions(+) diff --git a/pypln/__init__.py b/pypln/__init__.py index e69de29..ece379c 100644 --- a/pypln/__init__.py +++ b/pypln/__init__.py @@ -0,0 +1,2 @@ +import pkg_resources +pkg_resources.declare_namespace(__name__) diff --git a/setup.py b/setup.py index 69ef000..4ce7fcc 100644 --- a/setup.py +++ b/setup.py @@ -46,6 +46,7 @@ def get_requirements(): 'pypln-pipeliner = pypln.backend.pipeliner:main',], }, packages=find_packages(), + namespace_packages=["pypln"], install_requires=get_requirements(), test_suite='nose.collector', license='GPL3',