You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ii...@apache.org on 2019/09/11 13:45:33 UTC

[couchdb] branch prototype/fdb-layer updated: Support `--extra_args` parameter in `dev/run`

This is an automated email from the ASF dual-hosted git repository.

iilyak pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/prototype/fdb-layer by this push:
     new 91dfd3e  Support `--extra_args` parameter in `dev/run`
     new 5ffdb91  Merge pull request #2184 from cloudant/add-extra-arguments-to-beam
91dfd3e is described below

commit 91dfd3eb791bb398dc02a3afff8b9ea1b9a52421
Author: ILYA Khlopotov <ii...@apache.org>
AuthorDate: Tue Sep 10 11:30:46 2019 +0000

    Support `--extra_args` parameter in `dev/run`
    
    Sometimes there is a need to specify additional arguments for the beam process we start from dev/run.
    In particular the feature is handy for:
    - changing emulator flags
    - simulate OOM via available RAM restrictions
    - enable module loading tracing
    - configure number of schedulers
    - modify applications configuration
    - run customization script to add extra development deps (such as automatic code reload)
    
    Historically developers had to edit dev/run to do it.
    This PR adds an ability to specify additional arguments via `--extra_args` argument.
    
    In order to run customization script create `customization.erl` which exports `start/0` and run it using:
    ```
    dev/run --extra_args='-run customization'
    ```
---
 dev/run | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/dev/run b/dev/run
index 72f5a47..a8056eb 100755
--- a/dev/run
+++ b/dev/run
@@ -110,6 +110,11 @@ def setup_logging(ctx):
 
 
 def setup_argparse():
+    parser = get_args_parser()
+    return parser.parse_args()
+
+
+def get_args_parser():
     parser = optparse.OptionParser(description="Runs CouchDB 2.0 dev cluster")
     parser.add_option(
         "-a",
@@ -206,7 +211,13 @@ def setup_argparse():
         action="store_true",
         help="Select available ports for nodes automatically",
     )
-    return parser.parse_args()
+    parser.add_option(
+        "--extra_args",
+        dest="extra_args",
+        default=None,
+        help="Extra arguments to pass to beam process",
+    )
+    return parser
 
 
 def setup_context(opts, args):
@@ -230,6 +241,7 @@ def setup_context(opts, args):
         "config_overrides": opts.config_overrides,
         "erlang_config": opts.erlang_config,
         "no_eval": opts.no_eval,
+        "extra_args": opts.extra_args,
         "reset_logs": True,
         "procs": [],
         "auto_ports": opts.auto_ports,
@@ -585,6 +597,8 @@ def boot_node(ctx, node):
         mode = "r+b"
     logfname = os.path.join(ctx["devdir"], "logs", "%s.log" % node)
     log = open(logfname, mode)
+    if "extra_args" in ctx and ctx["extra_args"]:
+        cmd += ctx["extra_args"].split(" ")
     cmd = [toposixpath(x) for x in cmd]
     return sp.Popen(cmd, stdin=sp.PIPE, stdout=log, stderr=sp.STDOUT, env=env)