1. sodas tsai
  2. beanstalk-stack

Commits

sodas tsai  committed 2a1324e

Fix uwsgi path and sed command when working with multi-line text

  • Participants
  • Parent commits 2889e15
  • Branches master

Comments (0)

Files changed (3)

File beanstalk/__init__.py

View file
 
 # Pacakge information
 #-----------------------------------------------------------------------------------------------------------------------
-__version__ = '0.1.65'
+__version__ = '0.1.70'
 VERSION = tuple(map(lambda x: int(x), __version__.split('.')))
 BEANSTALK_ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
 

File beanstalk/paths/server.py

View file
 
 
 def project_uwsgi_path(project_name):
-    project_base = project_base_path(project_name)
-    return os.path.join(project_base, 'uwsgi.ini')
+    project_source = project_source_path(project_name)
+    return os.path.join(project_source, 'uwsgi.ini')
 
 
 def apache_conf_path():

File beanstalk/tasks/server.py

View file
             '#' + '-' * 20,
             ' ',
         ]
-        sed_command = '\\\n'.join(commands)
-        local(sed('$a\\{command}'.format(command=sed_command), apache_conf_path()))
+        sed_command = '\\n'.join(commands)
+        local(sed('$ a\\{command}'.format(command=sed_command), apache_conf_path()))
         local('sudo /usr/sbin/httpd_reload')
 
     port_file_path = os.path.join(project_base_path(project_name), '%d.port' % uwsgi_port)
         abort('No port number!?')
         return
     # edit ini
-    uwsgi_path = os.path.join(project_source_path(project_name), 'uwsgi.ini')
+    uwsgi_path = project_uwsgi_path(project_name)
     config = ConfigParser.ConfigParser()
     if os.path.exists(uwsgi_path):
         config.read(uwsgi_path)
     if not config.has_section('uwsgi'):
         config.add_section('uwsgi')
-        config.set('uwsgi', 'master', True)
-        config.set('uwsgi', 'enable-threads', True)
-        config.set('uwsgi', 'threads', 20)
-        config.set('uwsgi', 'processes', 4)
-        config.set('uwsgi', 'module', '%s.wsgi:application' % project_name)
-    config.set('uwsgi', 'socket', '127.0.0.1:%d' % uwsgi_port)
-    config.set('uwsgi', 'chdir', project_source_path(project_name))
-    config.set('uwsgi', 'home', project_venv_path(project_name))
+    optional_overrride_options = [
+        ('master', True),
+        ('enable-threads', True),
+        ('threads', 20),
+        ('processes', 4),
+        ('module', '%s.wsgi:application' % project_name),
+    ]
+    for key, value in optional_overrride_options:
+        if not config.has_option('uwsgi', key):
+            config.set('uwsgi', key, value)
+    must_override_options = [
+        ('socket', '127.0.0.1:%d' % uwsgi_port),
+        ('chdir', project_source_path(project_name)),
+        ('home', project_venv_path(project_name)),
+    ]
+    for key, value in must_override_options:
+        config.set('uwsgi', key, value)
     with hide('everything'):
         uid = local('id -u beanstalk', capture=True)
     config.set('uwsgi', 'uid', uid)