Massimiliano Ravelli avatar Massimiliano Ravelli committed fa669d9

fixed _setup_directories

Comments (0)

Files changed (3)

fagungis/conf/supervisord.conf

 [program:%(project)s]
-command=%(django_user_home)s/scripts/rungunicorn_%(project)s.sh
+command=%(rungunicorn_script)s
 directory=%(django_project_root)s
 user=%(django_user)s
 autostart=%(supervisor_autostart)s

fagungis/example_fabfile.py

     #  be sure to not have anything running on that port
     env.gunicorn_bind = "127.0.0.1:8100"
     env.gunicorn_logfile = '%(django_user_home)s/logs/projects/%(project)s_gunicorn.log' % env
+    env.rungunicorn_script = '%(django_user_home)s/scripts/rungunicorn_%(project)s.sh' % env
     env.gunicorn_workers = 2
     env.gunicorn_worker_class = "eventlet"
     env.gunicorn_loglevel = "info"
 
     ### START nginx settings ###
     env.nginx_server_name = 'example.com'  # Only domain name, without 'www' or 'http://'
+    env.nginx_conf_file = '%(django_user_home)s/configs/nginx/%(project)s.conf' % env
     env.nginx_client_max_body_size = 10  # Maximum accepted body size of client request, in MB
+    env.nginx_htdocs = '%(django_user_home)s/htdocs' % env
     ### END nginx settings ###
 
     ### START supervisor settings ###
     env.supervisor_autorestart = 'true'  # true or false
     env.supervisor_redirect_stderr = 'true'  # true or false
     env.supervisor_stdout_logfile = '%(django_user_home)s/logs/projects/supervisord_%(project)s.log' % env
+    env.supervisord_conf_file = '%(django_user_home)s/configs/supervisord/%(project)s.conf' % env
     ### END supervisor settings ###

fagungis/tasks.py

         errors.append('"gunicorn_logfile" configuration missing')
     elif verbose:
         parameters_info.append(('gunicorn_logfile', env.gunicorn_logfile))
+    if 'rungunicorn_script' not in env or not env.rungunicorn_script:
+        errors.append('"rungunicorn_script" configuration missing')
+    elif verbose:
+        parameters_info.append(('rungunicorn_script', env.rungunicorn_script))
     if 'gunicorn_workers' not in env or not env.gunicorn_workers:
         errors.append('"gunicorn_workers" configuration missing, you must have at least one worker')
     elif verbose:
         errors.append('"nginx_server_name" configuration missing')
     elif verbose:
         parameters_info.append(('nginx_server_name', env.nginx_server_name))
+    if 'nginx_conf_file' not in env or not env.nginx_conf_file:
+        errors.append('"nginx_conf_file" configuration missing')
+    elif verbose:
+        parameters_info.append(('nginx_conf_file', env.nginx_conf_file))
     if 'nginx_client_max_body_size' not in env or not env.nginx_client_max_body_size:
         errors.append('"nginx_client_max_body_size" configuration missing')
     elif not isinstance(env.nginx_client_max_body_size, int):
         errors.append('"nginx_client_max_body_size" must be an integer value')
     elif verbose:
         parameters_info.append(('nginx_client_max_body_size', env.nginx_client_max_body_size))
+    if 'nginx_htdocs' not in env or not env.nginx_htdocs:
+        errors.append('"nginx_htdocs" configuration missing')
+    elif verbose:
+        parameters_info.append(('nginx_htdocs', env.nginx_htdocs))
     if 'supervisorctl' not in env or not env.supervisorctl:
         errors.append('"supervisorctl" configuration missing')
     elif verbose:
         errors.append('"supervisor_stdout_logfile" configuration missing')
     elif verbose:
         parameters_info.append(('supervisor_stdout_logfile', env.supervisor_stdout_logfile))
+    if 'supervisord_conf_file' not in env or not env.supervisord_conf_file:
+        errors.append('"supervisord_conf_file" configuration missing')
+    elif verbose:
+        parameters_info.append(('supervisord_conf_file', env.supervisord_conf_file))
 
     if errors:
         if len(errors) == 26:
 
 def _setup_directories():
     sudo('mkdir -p %(projects_path)s' % env)
-    sudo('mkdir -p %(django_user_home)s/logs/nginx' % env)
-    sudo('mkdir -p %(django_user_home)s/logs/projects' % env)
-    sudo('mkdir -p %(django_user_home)s/configs/nginx' % env)
-    sudo('mkdir -p %(django_user_home)s/configs/supervisord' % env)
-    sudo('mkdir -p %(django_user_home)s/scripts' % env)
-    sudo('mkdir -p %(django_user_home)s/htdocs' % env)
-    sudo('mkdir -p %(django_user_home)s/tmp' % env)
+    # sudo('mkdir -p %(django_user_home)s/logs/nginx' % env)  # Not used
+    sudo('mkdir -p %s' % dirname(env.gunicorn_logfile))
+    sudo('mkdir -p %s' % dirname(env.supervisor_stdout_logfile))
+    sudo('mkdir -p %s' % dirname(env.nginx_conf_file))
+    sudo('mkdir -p %s' % dirname(env.supervisord_conf_file))
+    sudo('mkdir -p %s' % dirname(env.rungunicorn_script))
+    # sudo('mkdir -p %(django_user_home)s/tmp' % env)  # Not used
     sudo('mkdir -p %(virtenv)s' % env)
-    sudo('echo "<html><body>nothing here</body></html> " > %(django_user_home)s/htdocs/index.html' % env)
+    sudo('mkdir -p %(nginx_htdocs)s' % env)
+    sudo('echo "<html><body>nothing here</body></html> " > %(nginx_htdocs)s/index.html' % env)
 
 
 def virtenvrun(command):
 
 def _upload_nginx_conf():
     ''' upload nginx conf '''
-    nginx_file = '%(django_user_home)s/configs/nginx/%(project)s.conf' % env
     if isfile('conf/nginx.conf'):
         ''' we use user defined nginx.conf template '''
         template = 'conf/nginx.conf'
     else:
         template = '%s/conf/nginx.conf' % fagungis_path
-    upload_template(template, nginx_file,
+    upload_template(template, env.nginx_conf_file,
                     context=env, backup=False)
-    sudo('ln -sf %s /etc/nginx/sites-enabled/' % nginx_file)
+    sudo('ln -sf %s /etc/nginx/sites-enabled/' % env.nginx_conf_file)
     _test_nginx_conf()
     sudo('nginx -s reload')
 
 
 def _upload_supervisord_conf():
     ''' upload supervisor conf '''
-    supervisord_conf_file = '%(django_user_home)s/configs/supervisord/%(project)s.conf' % env
     if isfile('conf/supervisord.conf'):
         ''' we use user defined supervisord.conf template '''
         template = 'conf/supervisord.conf'
     else:
         template = '%s/conf/supervisord.conf' % fagungis_path
-    upload_template(template, supervisord_conf_file,
+    upload_template(template, env.supervisord_conf_file,
                     context=env, backup=False)
-    sudo('ln -sf %s /etc/supervisor/conf.d/' % supervisord_conf_file)
+    sudo('ln -sf %(supervisord_conf_file)s /etc/supervisor/conf.d/%(project)s.conf' % env)
     _reload_supervisorctl()
 
 
 
 def _upload_rungunicorn_script():
     ''' upload rungunicorn conf '''
-    script_file = '%(django_user_home)s/scripts/rungunicorn_%(project)s.sh' % env
     if isfile('scripts/rungunicorn.sh'):
         ''' we use user defined rungunicorn file '''
         template = 'scripts/rungunicorn.sh'
     else:
         template = '%s/scripts/rungunicorn.sh' % fagungis_path
-    upload_template(template, script_file,
+    upload_template(template, env.rungunicorn_script,
                     context=env, backup=False)
-    sudo('chmod +x %s' % script_file)
+    sudo('chmod +x %s' % env.rungunicorn_script)
 
 
 def _supervisor_restart():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.