Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ bin/
config.erl
*.tar.gz
*.tar.bz2
dev/boot_node.beam
dev/*.beam
dev/devnode.*
dev/lib/
dev/logs/
ebin/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ clean:
@rm -rf src/mango/.venv
@rm -f src/couch/priv/couchspawnkillable
@rm -f src/couch/priv/couch_js/config.h
@rm -f dev/boot_node.beam dev/pbkdf2.pyc log/crash.log
@rm -f dev/*.beam dev/devnode.* dev/pbkdf2.pyc log/crash.log


.PHONY: distclean
Expand Down
148 changes: 0 additions & 148 deletions dev/boot_node.erl

This file was deleted.

9 changes: 9 additions & 0 deletions dev/make_boot_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env escript

main(_) ->
{ok, Server} = reltool:start_server([
{config, "../rel/reltool.config"}
]),
{ok, Release} = reltool:get_rel(Server, "couchdb"),
ok = file:write_file("devnode.rel", io_lib:format("~p.~n", [Release])),
ok = systools:make_script("devnode", [local]).
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really where the magic happens -- we take the existing reltool.config file and generate a .boot script with the local option, which automatically uses the existing paths for all the modules instead of relocatable ones like we have in the actual release.

43 changes: 43 additions & 0 deletions dev/monitor_parent.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
% License for the specific language governing permissions and limitations under
% the License.

-module(monitor_parent).

-export([start/0]).


start() ->
{ok, [[PPid]]} = init:get_argument(parent_pid),
spawn(fun() -> monitor_parent(PPid) end).


monitor_parent(PPid) ->
timer:sleep(1000),
case os:type() of
{unix, _} ->
case os:cmd("kill -0 " ++ PPid) of
"" ->
monitor_parent(PPid);
_Else ->
% Assume _Else is a no such process error
init:stop()
end;
{win32, _} ->
Fmt = "tasklist /fi \"PID eq ~s\" /fo csv /nh",
Retval = os:cmd(io_lib:format(Fmt, [PPid])),
case re:run(Retval, "^\"python.exe\",*") of
{match, _} ->
monitor_parent(PPid);
nomatch ->
init:stop()
end
end.
17 changes: 13 additions & 4 deletions dev/run
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def setup():
setup_logging(ctx)
setup_dirs(ctx)
check_beams(ctx)
check_boot_script(ctx)
setup_configs(ctx)
return ctx

Expand Down Expand Up @@ -268,6 +269,14 @@ def check_beams(ctx):
sp.check_call(["erlc", "-o", ctx["devdir"] + os.sep, fname])


@log("Ensure Erlang boot script exists")
def check_boot_script(ctx):
if not os.path.exists(os.path.join(ctx["devdir"], "devnode.boot")):
env = os.environ.copy()
env["ERL_LIBS"] = os.path.join(ctx["rootdir"], "src")
sp.check_call(["escript", "make_boot_script"], env=env, cwd=ctx["devdir"])


@log("Prepare configuration files")
def setup_configs(ctx):
for idx, node in enumerate(ctx["nodes"]):
Expand Down Expand Up @@ -592,10 +601,9 @@ def set_boot_env(ctx):

@log("Start node {node}")
def boot_node(ctx, node):
erl_libs = os.path.join(ctx["rootdir"], "src")
set_boot_env(ctx)
env = os.environ.copy()
env["ERL_LIBS"] = os.pathsep.join([erl_libs])
env["ERL_LIBS"] = os.path.join(ctx["rootdir"], "src")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure what was going on here with the os.pathsep.join piece, since there's only one path. It felt like a vestigial thing. I cleaned it up to match the same dance being done in the check_boot_script method.


node_etcdir = os.path.join(ctx["devdir"], "lib", node, "etc")
reldir = os.path.join(ctx["rootdir"], "rel")
Expand All @@ -614,11 +622,12 @@ def boot_node(ctx, node):
os.path.join(reldir, "reltool.config"),
"-parent_pid",
str(os.getpid()),
"-boot",
os.path.join(ctx["devdir"], "devnode"),
"-pa",
ctx["devdir"],
"-s monitor_parent",
]
cmd += [p[:-1] for p in glob.glob(erl_libs + "/*/")]
cmd += ["-s", "boot_node"]
if ctx["reset_logs"]:
mode = "wb"
else:
Expand Down