Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: EchoTeam/rebar-templates
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.0.0
Choose a base ref
...
head repository: EchoTeam/rebar-templates
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 17 commits
  • 9 files changed
  • 10 contributors

Commits on Jan 16, 2014

  1. Update DEV.md

    lukyanov committed Jan 16, 2014
    Copy the full SHA
    6f6136a View commit details

Commits on Jan 17, 2014

  1. Copy the full SHA
    8f5f776 View commit details
  2. Copy the full SHA
    863423e View commit details
  3. Copy the full SHA
    7a102ac View commit details

Commits on Jan 28, 2014

  1. Copy the full SHA
    6521c49 View commit details

Commits on Feb 3, 2014

  1. More correct way to read erlang cookie.

    The start scipts searches for $HOME/.erlang.cookie first, then tries to read cookie from vm.args.
    lukyanov committed Feb 3, 2014
    Copy the full SHA
    2e1d3ac View commit details

Commits on Feb 4, 2014

  1. Temp directory names now contain whoami to prevent conflicts when a…

    … service is run under different users.
    lukyanov committed Feb 4, 2014
    Copy the full SHA
    87e40f9 View commit details

Commits on Feb 18, 2014

  1. Copy the full SHA
    8bb295a View commit details

Commits on Feb 20, 2014

  1. Remove release in any release status - old, permanent, current, unpac…

    …ked.
    Petrovsky Alexander committed Feb 20, 2014
    Copy the full SHA
    192d596 View commit details

Commits on Mar 1, 2014

  1. changed git clone instruction

    The "git clone [email protected]" style clones over SSH, which requires you to have a GitHub account with an SSH public key configured, this is less friendly. Thus i changed it to git://github.com 
    
    byaruhaf@JATIVA:~$ mkdir -p ~/.rebar/templates
    byaruhaf@JATIVA:~$ git clone [email protected]:EchoTeam/rebar-templates.git ~/.rebar/templates
    Cloning into '/home/byaruhaf/.rebar/templates'...
    The authenticity of host 'github.com (192.30.252.131)' can't be established.
    RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
    Are you sure you want to continue connecting (yes/no)? y
    Please type 'yes' or 'no': yes
    Warning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of known hosts.
    Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    byaruhaf@JATIVA:~$ git clone git://github.com/EchoTeam/rebar-templates.git ~/.rebar/templates
    Cloning into '/home/byaruhaf/.rebar/templates'...
    remote: Reusing existing pack: 622, done.
    remote: Total 622 (delta 0), reused 0 (delta 0)
    Receiving objects: 100% (622/622), 563.93 KiB | 58.00 KiB/s, done.
    Resolving deltas: 100% (386/386), done.
    Checking connectivity... done
    byaruhaf@JATIVA:~$
    byaruhaf committed Mar 1, 2014
    Copy the full SHA
    38b8031 View commit details
  2. Merge pull request #1 from byaruhaf/patch-1

    changed git clone instruction
    alvelcom committed Mar 1, 2014
    Copy the full SHA
    02c566f View commit details

Commits on Jul 2, 2014

  1. Fixed typos

    zaa committed Jul 2, 2014
    Copy the full SHA
    74578b9 View commit details

Commits on Sep 15, 2014

  1. Fix URL to clone git repo

    marfeyh committed Sep 15, 2014
    Copy the full SHA
    ce9609e View commit details
  2. Merge pull request #3 from marfeyh/bug/git_url

    Fix URL to clone git repo
    gliush committed Sep 15, 2014
    Copy the full SHA
    19df2f3 View commit details

Commits on Sep 28, 2014

  1. Copy the full SHA
    3da7815 View commit details

Commits on Sep 29, 2014

  1. Merge pull request #4 from donpiekarz/master

    Fix git URLs in rebar's deps
    zaa committed Sep 29, 2014
    Copy the full SHA
    84efd29 View commit details
  2. Fixed git clone repo URL

    zaa committed Sep 29, 2014
    Copy the full SHA
    9e43ec6 View commit details
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ To make the templates available, you need to clone the repo to your
`~/.rebar/templates` directory:

mkdir -p ~/.rebar/templates
git clone git@github.com:EchoTeam/rebar-templates.git ~/.rebar/templates
git clone git://github.com/EchoTeam/rebar-templates.git ~/.rebar/templates

## Creating Erlang/OTP service layout

8 changes: 3 additions & 5 deletions service/DEV.md
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ in detached state ("Not currently at any branch").

$ cd deps/{your_app}
$ vim src/*.erl # meaning you change your code in some way
$ OLD_REV=`git rev-parse HEAD` # meaning your just now the current rev
$ OLD_REV=`git rev-parse HEAD` # meaning your just know the current rev
$ git commit
$ genappup $OLD_REV

@@ -89,19 +89,17 @@ And if you also want your applciation to be automatically started, change "rel"
{rel,"{{name}}","RELVSN",
[kernel,sasl,stdlib,lager,corman,your_new_app]},

### Cheking how target system build works:
### Checking how target system build (release) works:

$ make target

### Cheking how upgrade works:
### Checking how upgrade works:

$ git checkout {an_older_rev} # checking out a specific past git revision
$ make clean
$ make run-no-sync # no-sync as we do not want modules to be auto-loaded
$ git checkout master # checking out the current revision
$ make upgrade



### See also:
[Makefile targets](MAKE.md)
1 change: 1 addition & 0 deletions service/project.mk
Original file line number Diff line number Diff line change
@@ -81,6 +81,7 @@ generate: update-deps compile rel

clean: pre-clean
$(REBAR) clean
rm -f rel/reltool.config
rm -rf rel/$(SERVICE_NAME)*
$(MAKE) post-clean

4 changes: 2 additions & 2 deletions service/rebar.config
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
{git, "git://github.com/basho/lager.git",
{tag, "2.0.1"}}},
{echo_rebar_plugins, ".*",
{git, "git@github.com:EchoTeam/rebar-plugins.git",
{git, "git://github.com/EchoTeam/rebar-plugins.git",
{branch, "master"}}},
%%% /Note

@@ -25,7 +25,7 @@
{git, "git://github.com/rustyio/sync.git",
{branch, "master"}}},
{corman, ".*",
{git, "git@github.com:EchoTeam/corman.git",
{git, "git://github.com/EchoTeam/corman.git",
{branch, "master"}}}
]}.

2 changes: 1 addition & 1 deletion service/rel/files/install_upgrade.escript
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
%% ex: ft=erlang ts=4 sw=4 et

-define(TIMEOUT, 60000).
-define(INFO(Fmt,Args), io:format(Fmt,Args)).
-define(INFO(Fmt, Args), io:format(Fmt, Args)).

main([NodeName, Cookie, ReleasePackage]) ->
TargetNode = start_distribution(NodeName, Cookie),
37 changes: 15 additions & 22 deletions service/rel/files/remove_release.escript
Original file line number Diff line number Diff line change
@@ -4,21 +4,21 @@
%% ex: ft=erlang ts=4 sw=4 et

-define(TIMEOUT, 60000).
-define(INFO(Fmt,Args), io:format(Fmt,Args)).
-define(ERR(Fmt,Args), begin io:format(Fmt,Args), halt(1) end).
-define(INFO(Fmt, Args), io:format(Fmt, Args)).
-define(ERR(Fmt, Args), begin io:format(Fmt, Args), halt(1) end).

main([NodeName, Cookie, RelToDel, BackRel]) ->
TargetNode = start_distribution(NodeName, Cookie),
case rpc:call(TargetNode, release_handler, which_releases,[], ?TIMEOUT) of
ListReleases when is_list(ListReleases) -> %% [{Name, Vsn, Apps, Status }]
%% check the status of RelToDel
case [Status || {_,R,_,Status} <- ListReleases, R == RelToDel ] of
[S] -> remove_rls(TargetNode,S, RelToDel, BackRel);
[] -> ?ERR("No such release was installed ~p~n",[RelToDel]);
Else -> ?ERR("Cannot get status of ~p (~p)~n",[RelToDel,Else])
[S] -> remove_rls(TargetNode, S, RelToDel, BackRel);
[] -> ?ERR("No such release was installed ~p~n", [RelToDel]);
Else -> ?ERR("Cannot get status of ~p (~p)~n", [RelToDel,Else])
end;
Else -> ?ERR("Cannot get list of releases ~p~n",[Else])
end;
Else -> ?ERR("Cannot get list of releases ~p~n", [Else])
end;

main(_) ->
halt(1).
@@ -44,23 +44,16 @@ make_target_node(Node) ->
make_script_node(Node) ->
list_to_atom(lists:concat([Node, "_remover_", os:getpid()])).

remove_rls(TargetNode,old,RelToDel,_) ->
ok = rpc:call(TargetNode,release_handler, remove_release,[RelToDel],?TIMEOUT),
?INFO("Release ~p is removed",[RelToDel]);

remove_rls(TargetNode,permanent,RelToDel,BackRel) ->
{ok, _, Desc} = rpc:call(TargetNode, release_handler,check_install_release, [BackRel], ?TIMEOUT),
{ok, _, Desc} = rpc:call(TargetNode, release_handler,install_release, [BackRel], ?TIMEOUT),
remove_rls(TargetNode, permanent, RelToDel, BackRel) ->
{ok, _, Desc} = rpc:call(TargetNode, release_handler, check_install_release, [BackRel], ?TIMEOUT),
{ok, _, Desc} = rpc:call(TargetNode, release_handler, install_release, [BackRel], ?TIMEOUT),
?INFO("Installed Release ~p~n", [BackRel]),
ok = rpc:call(TargetNode, release_handler, make_permanent, [BackRel], ?TIMEOUT),
?INFO("Made Release ~p Permanent~n", [BackRel]),
ok = rpc:call(TargetNode,release_handler, remove_release,[RelToDel],?TIMEOUT),
?INFO("Release ~p is removed",[RelToDel]).






ok = rpc:call(TargetNode,release_handler, remove_release, [RelToDel], ?TIMEOUT),
?INFO("Release ~p is removed", [RelToDel]);

remove_rls(TargetNode, _, RelToDel, _) ->
ok = rpc:call(TargetNode, release_handler, remove_release, [RelToDel], ?TIMEOUT),
?INFO("Release ~p is removed", [RelToDel]).

66 changes: 38 additions & 28 deletions service/rel/files/service
Original file line number Diff line number Diff line change
@@ -63,7 +63,7 @@ if ! [ -d ${RUNNER_ETC_DIR} ]; then
RUNNER_ETC_DIR=$RUNNER_BASE_DIR/etc
fi
# Note the trailing slash on $PIPE_DIR/
PIPE_DIR=/tmp/$SERVNAME.pipe/
PIPE_DIR=/tmp/${SERVNAME}.${RUNNER_USER}.pipe/

# Make sure this script is running as the appropriate user
if ([ "$RUNNER_USER" ] && [ "x$WHOAMI" != "x$RUNNER_USER" ]); then
@@ -125,23 +125,26 @@ if [ -z $HOST_IN_NAME ] ; then
RUNHOST=`hostname -s`
else
RUNHOST=$HOST_IN_NAME
fi
fi

# Note the `date +%s`, used to allow multiple remsh to the same node
# transparently
REMSH_NAME_ARG="$REMSH_TYPE remsh`date +%s`@$RUNHOST"
REMSH_REMSH_ARG="-remsh $REMSH_NAME@$RUNHOST"

# Extract the target cookie
#COOKIE_ARG=`grep '^\-setcookie' $VMARGS_PATH`
#if [ -z "$COOKIE_ARG" ]; then
# echo "vm.args needs to have a -setcookie parameter."
# exit 1
#fi

COOKIE=`cat $HOME/.erlang.cookie`
COOKIE_ARG="-setcookie $COOKIE"

if [ -r $HOME/.erlang.cookie ]; then
COOKIE=`cat $HOME/.erlang.cookie`
COOKIE_ARG="-setcookie $COOKIE"
else
COOKIE_ARG=`grep '^\-setcookie' $VMARGS_PATH`
if [ -n "$COOKIE_ARG" ]; then
COOKIE=`echo $COOKIE_ARG | awk '{print $2}'`
else
echo "Erlang cookie not found."
exit 1
fi
fi

# Make sure CWD is set to the right dir
cd $USE_DIR
@@ -153,7 +156,7 @@ mkdir -p $USE_DIR/log
ERTS_PATH=$RUNNER_BASE_DIR/erts-$ERTS_VSN/bin

# Setup command to control the node
NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG"
NODETOOL="$ERTS_PATH/escript $ERTS_PATH/nodetool $NAME_ARG $COOKIE_ARG"

# Setup remote shell command to control node
REMSH="$ERTS_PATH/erl $REMSH_NAME_ARG $REMSH_REMSH_ARG $COOKIE_ARG"
@@ -170,7 +173,7 @@ get_pid() {
PID=`$NODETOOL getpid < /dev/null`
ES=$?
if [ "$ES" -ne 0 ]; then
echo "Node is not running!"
echo "Node is not running!" 1>&2
return 1
fi

@@ -183,7 +186,7 @@ get_pid() {
}




# Check the first argument for instructions
case "$1" in
@@ -192,7 +195,7 @@ case "$1" in
RES=`ping_node`
if [ "$RES" = "pong" ]; then
echo "Node is already running!"
exit 1
exit 0
fi
case "$1" in
start)
@@ -219,7 +222,7 @@ case "$1" in
[ -n "$THISISRESTART" ] && sleep 5

$ERTS_PATH/run_erl -daemon $PIPE_DIR $RUNNER_LOG_DIR "exec $RUNNER_BASE_DIR/bin/$SCRIPT $START_OPTION $RUN_PARAM" 2>&1
) 9>/tmp/${SERVNAME}_restart
) 9>/tmp/${SERVNAME}.${RUNNER_USER}.restart
;;

stop)
@@ -284,7 +287,7 @@ case "$1" in
ping_node
ES=$?
if [ "$ES" -ne 0 ]; then
echo "Node is not running!"
echo "Node is not running!" 1>&2
exit $ES
fi

@@ -297,7 +300,7 @@ case "$1" in
ping_node
ES=$?
if [ "$ES" -ne 0 ]; then
echo "Node is not running!"
echo "Node is not running!" 1>&2
exit $ES
fi

@@ -317,14 +320,13 @@ case "$1" in
ping_node
ES=$?
if [ "$ES" -ne 0 ]; then
echo "Node is not running!"
echo "Node is not running!" 1>&2
exit $ES
fi

node_name=`echo $NAME_ARG | awk '{print $2}'`
erlang_cookie=$COOKIE

$ERTS_PATH/escript $RUNNER_BASE_DIR/bin/install_upgrade.escript $node_name $erlang_cookie $2
$ERTS_PATH/escript $RUNNER_BASE_DIR/bin/install_upgrade.escript $node_name $COOKIE $2
;;

remove_release)
@@ -339,19 +341,17 @@ case "$1" in
exit 1
fi


# Make sure a node IS running
ping_node
ES=$?
if [ "$ES" -ne 0 ]; then
echo "Node is not running!"
echo "Node is not running!" 1>&2
exit $ES
fi

node_name=`echo $NAME_ARG | awk '{print $2}'`
erlang_cookie=$COOKIE

$ERTS_PATH/escript $RUNNER_BASE_DIR/bin/remove_release.escript $node_name $erlang_cookie $2 $3
$ERTS_PATH/escript $RUNNER_BASE_DIR/bin/remove_release.escript $node_name $COOKIE $2 $3
;;

console|console_clean|console_boot)
@@ -422,11 +422,21 @@ case "$1" in
exit $ES
fi
echo $PID
exit 0
;;
relvsn)
## See if the VM is alive
RES=`ping_node`
if [ "$RES" != "pong" ]; then
echo "Node is not running!" 1>&2
exit 1
fi
ERL="$ERTS_PATH/erl $REMSH_NAME_ARG $COOKIE_ARG"
erlang_cmd="io:format(\"~s~n\", [hd([Vsn || {_, Vsn, _, permanent} <- rpc:call($REMSH_NAME@$RUNHOST, release_handler, which_releases, [])])])."
exec $ERL -noshell -eval "$erlang_cmd" -s erlang halt
;;
*)
echo "Usage: $SCRIPT {start|start_boot <file>|foreground|stop|restart|reboot|ping|console|getpid|console_clean|console_boot <file>|attach|remote_console|upgrade}"
echo "Usage: $SCRIPT {start|start_boot <file>|foreground|stop|restart|reboot|ping|console|getpid|console_clean|console_boot <file>|attach|remote_console|upgrade|relvsn}"
exit 1
;;
esac

exit 0
5 changes: 0 additions & 5 deletions service/rel/files/sys.config
Original file line number Diff line number Diff line change
@@ -22,11 +22,6 @@
{non_descendants, allow}
]},

{node_mon, [
%{start_expectations, [application_loaded, node_ready]}
{start_expectations, []}
]},

%%% Dynamic part (differs from one environment to another)
"{{config_dir}}/app.config"

2 changes: 1 addition & 1 deletion service/rel/files/vm.args
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
-sname {{service_name}}

## Cookie for distributed erlang
#-setcookie XXX
# -setcookie {{service_name}}

## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
## (Disabled by default..use with caution!)