Repository: Kinto/kinto

Issue:
Docker doesn't start anymore because config/kinto.ini doesn't exists.
![v37hk](https://cloud.githubusercontent.com/assets/229453/11350267/fa909648-9230-11e5-8920-a7740b8b671c.png)



Discussion:

Resolving patch:
diff --git a/kinto/__main__.py b/kinto/__main__.py
--- a/kinto/__main__.py
+++ b/kinto/__main__.py
@@ -2,6 +2,7 @@
 import argparse
 import os
 import sys
+from six.moves import input
 from cliquet.scripts import cliquet
 from pyramid.scripts import pserve
 from pyramid.paster import bootstrap
@@ -22,6 +23,11 @@ def main(args=None):
                         dest='ini_file',
                         required=False,
                         default=CONFIG_FILE)
+    parser.add_argument('--backend',
+                        help='Specify backend',
+                        dest='backend',
+                        required=False,
+                        default=None)
 
     subparsers = parser.add_subparsers(title='subcommands',
                                        description='valid subcommands',
@@ -40,12 +46,25 @@ def main(args=None):
     config_file = args['ini_file']
 
     if args['which'] == 'init':
-        if not os.path.exists(config_file):
-            init(config_file)
-        else:
+        if os.path.exists(config_file):
             print("%s already exist." % config_file, file=sys.stderr)
             sys.exit(1)
 
+        backend = args['backend']
+        if not backend:
+            while True:
+                prompt = ("Which backend to use? "
+                          "(1 - postgresql, 2 - redis, default - memory) ")
+                answer = input(prompt).strip()
+                try:
+                    backends = {"1": "postgresql", "2": "redis", "": "memory"}
+                    backend = backends[answer]
+                    break
+                except KeyError:
+                    pass
+
+        init(config_file, backend)
+
     elif args['which'] == 'migrate':
         env = bootstrap(config_file)
         cliquet.init_schema(env)
diff --git a/kinto/config/__init__.py b/kinto/config/__init__.py
--- a/kinto/config/__init__.py
+++ b/kinto/config/__init__.py
@@ -1,7 +1,6 @@
 import os
 import binascii
 import codecs
-from six.moves import input
 
 HERE = os.path.abspath(os.path.dirname(__file__))
 
@@ -16,39 +15,29 @@ def render_template(template, destination, **kwargs):
             output.write(rendered)
 
 
-def init(config_file):
+def init(config_file, backend):
     values = {}
     values['secret'] = binascii.b2a_hex(os.urandom(32))
 
-    backend = input("Which backend to use? "
-                    "(1 - postgresql, 2 - redis, default - memory) ").strip()
+    values['storage_backend'] = "cliquet.storage.%s" % backend
+    values['cache_backend'] = "cliquet.cache.%s" % backend
+    values['permission_backend'] = "cliquet.permission.%s" % backend
 
-    if backend == '1':
-        # Postgresql configuration
+    if backend == 'postgresql':
         postgresql_url = "postgres://postgres:postgres@localhost/postgres"
-        values['storage_backend'] = "cliquet.storage.postgresql"
         values['storage_url'] = postgresql_url
-        values['cache_backend'] = "cliquet.cache.postgresql"
         values['cache_url'] = postgresql_url
-        values['permission_backend'] = "cliquet.permission.postgresql"
         values['permission_url'] = postgresql_url
 
-    elif backend == '2':
-        # Redis configuration
-        values['storage_backend'] = "cliquet.storage.redis"
-        values['storage_url'] = "redis://localhost:6379/1"
-        values['cache_backend'] = "cliquet.cache.redis"
-        values['cache_url'] = "redis://localhost:6379/2"
-        values['permission_backend'] = "cliquet.permission.redis"
-        values['permission_url'] = "redis://localhost:6379/3"
+    elif backend == 'redis':
+        redis_url = "redis://localhost:6379"
+        values['storage_url'] = redis_url + "/1"
+        values['cache_url'] = redis_url + "/2"
+        values['permission_url'] = redis_url + "/3"
 
     else:
-        # Memory configuration / default backend
-        values['storage_backend'] = "cliquet.storage.memory"
-        values['storage_url'] = ""
-        values['cache_backend'] = "cliquet.cache.memory"
-        values['cache_url'] = ""
-        values['permission_backend'] = "cliquet.permission.memory"
-        values['permission_url'] = ""
+        values['storage_url'] = ''
+        values['cache_url'] = ''
+        values['permission_url'] = ''
 
     render_template("kinto.tpl", config_file, **values)


Test patch: