anchor.diff:                                                          {"[[USER]]", App#app.user}
                                                         ]),
     % START INSTANCE
  -  % P = spawn(fun() -> os:cmd(NewCmd) end),
     % port_handler:start("thin -R beehive.ru --port 5000 start", "/Users/auser/Development/erlang/mine/router/test/fixtures/apps").
     ?LOG(info, "Starting on port ~p as ~p:~p with ~p", [Port, App#app.group, App#app.user, RealCmd]),
  -  Pid = port_handler:start(RealCmd, App#app.path),
  +  Pid = port_handler:start(RealCmd, App#app.path, self()),
     Host = host:myip(),
     Id = {App#app.name, Host, Port},
     
  
positive.code: %%% Author  : Ari Lerner
  %%% Description : 
  %%%
  %%% Created :  Wed Nov 18 16:10:17 PST 2009
  %%%-------------------------------------------------------------------
  
  -module (app_handler).
  -include ("router.hrl").
  -include ("common.hrl").
  
  -export ([
    start_link/0,
    stop/0,
    start_new_instance/3,
    stop_instance/3
  ]).
  
  start_link() ->  
    Opts = [named_table, set],
    ets:new(?MODULE, Opts),
    Pid = spawn(fun() -> loop() end),
    register(?MODULE, Pid),
    {ok, Pid}.
    
  stop() ->
    ?MODULE ! {stop}.
    
  loop() ->
    receive
      {stop} ->
        ok;
      _X -> 
        loop()
    end.
  
  % Start a new instance of the application
  start_new_instance(App, Port, From) ->
    ?LOG(info, "App ~p", [App]),
    
    TemplateCommand = App#app.start_command,
  
negative.code:   },
    
    From ! {started_backend, Backend},
    ets:insert(?MODULE, {Id, Backend}),
    Backend.
  
  % kill the instance of the application  
  internal_stop_instance(Backend, App, From) ->
    RealCmd = template_command_string(App#app.stop_command, [
                                                          {"[[PORT]]", erlang:integer_to_list(Backend#backend.port)},
                                                          {"[[GROUP]]", App#app.group},
  