From 85be59976e086408f603ad9be591491fcf2f0f53 Mon Sep 17 00:00:00 2001 From: Marc Aymerich Date: Tue, 5 May 2015 20:55:54 +0000 Subject: [PATCH] Fixes on deploy.sh --- TODO.md | 2 ++ orchestra/management/commands/setupnginx.py | 17 +++++++++++------ scripts/container/deploy.sh | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/TODO.md b/TODO.md index e36e427b..76429a93 100644 --- a/TODO.md +++ b/TODO.md @@ -380,3 +380,5 @@ try: import uwsgi to know its running uwsgi # LOCK beat lockfile + +# Deprecate restart/start/stop services (do touch wsgi.py and fuck celery) diff --git a/orchestra/management/commands/setupnginx.py b/orchestra/management/commands/setupnginx.py index f7258456..8ab1ffa1 100644 --- a/orchestra/management/commands/setupnginx.py +++ b/orchestra/management/commands/setupnginx.py @@ -18,7 +18,7 @@ class Command(BaseCommand): help='Nginx SSL certificate, one will be created by default.'), make_option('--cert-key', dest='cert_key', default='', help='Nginx SSL certificate key.'), - + make_option('--cert-path', dest='cert_path', default='/etc/nginx/ssl/orchestra.crt', help='Nginx SSL certificate, one will be created by default.'), make_option('--cert-key-path', dest='cert_key_path', default='/etc/nginx/ssl/orchestra.key', @@ -40,7 +40,7 @@ class Command(BaseCommand): help='Certificate Distinguished Name Email Address.'), make_option('--cert-common_name', dest='cert_common_name', default=None, help='Certificate Distinguished Name Common Name.'), - + make_option('--server-name', dest='server_name', default='', help='Nginx SSL certificate key.'), make_option('--user', dest='user', default='', @@ -132,7 +132,6 @@ class Command(BaseCommand): self.stdout.write('writing new cert to \'%s\'' % cert_path) self.stdout.write('writing new cert key to \'%s\'' % key_path) run('openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout %(key_path)s -out %(cert_path)s -subj "%(subject)s"' % context, display=True) - return cert_path, key_path @check_root @@ -204,7 +203,7 @@ class Command(BaseCommand): """ ) % context - nginx_file = '/etc/nginx/conf.d/%(project_name)s.conf' % context + nginx_file = '/etc/nginx/sites-available/%(project_name)s.conf' % context if server_name: context['server_name'] = server_name nginx_file = '/etc/nginx/sites-available/%(server_name)s.conf' % context @@ -242,8 +241,14 @@ class Command(BaseCommand): "The old version has been placed at %(file)s.save\033[m" % context) if server_name: - run('ln -s /etc/nginx/sites-available/%(server_name)s.conf /etc/nginx/sites-enabled/' % context, error_codes=[0,1], display=True) - run('ln -s /etc/uwsgi/apps-available/%(project_name)s.ini /etc/uwsgi/apps-enabled/' % context, error_codes=[0,1], display=True) + run('ln -s /etc/nginx/sites-available/%(server_name)s.conf /etc/nginx/sites-enabled/' % context, + error_codes=[0,1], display=True) + else: + run('rm /etc/nginx/sites-enabled/default') + run('ln -s /etc/nginx/sites-available/%(project_name)s.conf /etc/nginx/sites-enabled/' % context, + error_codes=[0,1], display=True) + run('ln -s /etc/uwsgi/apps-available/%(project_name)s.ini /etc/uwsgi/apps-enabled/' % context, + error_codes=[0,1], display=True) rotate = textwrap.dedent("""\ /var/log/nginx/*.log { diff --git a/scripts/container/deploy.sh b/scripts/container/deploy.sh index efd2fbc6..3ea1479b 100755 --- a/scripts/container/deploy.sh +++ b/scripts/container/deploy.sh @@ -117,7 +117,7 @@ run "$PYTHON_BIN $MANAGE setupnginx --user $USER --noinput" run "service nginx start" # Apply changes on related services -run "$PYTHON_BIN $MANAGE restartservices" +run "$PYTHON_BIN $MANAGE restartservices" || true # Create orchestra superuser cat <<- EOF | $PYTHON_BIN $MANAGE shell