GETENV_PARAM tmp prospero_root_script
clear_param empty
IF VAL1=$(tmp) VAL2=$(empty) STRATEGY=ELSE_END
ELSE
* calc_param _ANALIZ_BIN $(tmp)\Namechecking\p.Secco processing nodes\std.oracle\lexEngine
END

calc_param dir $(_ANALIZ_BIN)\AnalizServices\lexEngineService


i $(bin)\AnalizServices\init.rc

##LUA_EXECUTE_FILE lua $(dir)\lua\servv.lua
##LUA_EXECUTE_FILE lua $(dir)\lua\serv.lua


##LUA_EXECUTE_FILE lua $(dir)\lua\finasServ.lua

ORACLE_MQ_LUA_REG lua_engine


##i $(dir)\..\serv\ora_init.rc
##LUA_EXECUTE_FILE lua $(dir)\..\serv\lua\serv_oracle.lua
##LUA_EXECUTE_FILE lua $(dir)\lua\finnova_serv.lua
include $(dir)\log_level_setting.rc

calc_param service_name_short $(UNIQUE_IDENTIFIER)
set_param service_family finas
GET_CURRENT_PROCESS_ID pid


calc_param dir $(bin)\AnalizServices\lexEngineService
calc_param log_prefix $(UNIQUE_IDENTIFIER)
calc_param service_name_short $(UNIQUE_IDENTIFIER)


calc_param service_family FinasMQ

LUA_EXECUTE_BLOCK_BEGIN lua

  local ss = analiz.libs.serv

  local is_service = analiz:get("_IS_SERVICE")=="1"

  local family_tag = analiz:get("UNIQUE_IDENTIFIER")



 if is_service then
   analiz:set("prospero_temp",GetRootTempDir())
   analiz:execute("calc_param txm_temp_root_dir $(prospero_temp)")
   analiz:execute("echo FORCEDIRECTORIES $(txm_temp_root_dir)\\lex\\$(service_family)\\$(service_name_short)")
   analiz:execute("FORCEDIRECTORIES $(txm_temp_root_dir)\\lex\\$(service_family)\\$(service_name_short)")
   analiz:execute("calc_param LOG_FORMAT $(txm_temp_root_dir)\\lex\\$(service_family)\\$(service_name_short)\\log.log")

   analiz:execute("calc_param LOG_FORMAT_dir $(txm_temp_root_dir)\\lex\\$(service_family)\\$(service_name_short)")

   analiz:execute("echo !2! FORCEDIRECTORIES $(LOG_FORMAT_dir)")
   analiz:execute("FORCEDIRECTORIES $(LOG_FORMAT_dir)")
   analiz:execute("calc_param LOG_FORMAT_t $(LOG_FORMAT_dir)")


   analiz:set("LOG_FORMAT",analiz:get("LOG_FORMAT_t").."\\log_$(DATE_FOR_LOG_FILE).log")

   local m =  analiz:map_new("log_map")
   analiz:execute("calc_param start_dt $(now)")

   m:set("start_dt",analiz:get("tmp"))
   m:set("pid",analiz:get("PID"))
   m:set("UNIQUE_IDENTIFIER",analiz:get("UNIQUE_IDENTIFIER"))
   m:set("SERVICE_NAME",analiz:get("SERVICE_NAME"))  

   analiz:execute("calc_formula_int SizePiecesM 5*1024")
   analiz:execute("echo CREATE_LOG_CIRCULAR_FILE clog $(LOG_FORMAT) $(SizePiecesM) 5 1 log_map")
   analiz:execute("echo USE_LOG clog STD")
   analiz:execute(" echo USE_LOG clog error")
   analiz:execute("CHANGE_SERVICE_LOG_PARAM LOG_FORMAT")
 end   

LUA_END

echo $(new_line)$(new_line)$(new_line)$(new_line)$(new_line)$(new_line)start service:$(UNIQUE_IDENTIFIER). $(now)
echo -----------------------------------------------------------------------------------------
echo -----------------------------------------------------------------------------------------
echo -----------------------------------------------------------------------------------------
echo -----------------------------------------------------------------------------------------
echo start $(service_family):$(UNIQUE_IDENTIFIER)
echo pid=$(pid)
echo host:$(COMPUTERNAME)
echo $(new_line)$(new_line)$(new_line)


LUA_EXECUTE_BLOCK_BEGIN lua
  local ss = analiz.libs.serv
  deadline = CreateDeadlineEngineForX("finas")
  ss.e("ANALIZ_SAFE_EXECUTE ret emessage LUA_EXECUTE_FILE lua $(dir)\\..\\finasServMQ.lua")
  deadline:Finish()
LUA_END

##LUA_EXECUTE_LINE lua check_and_fix_lua_failed(analiz:get("emessage"))
LUA_EXECUTE_LINE lua Check_and_fix_lua_failed(analiz:get("emessage"))

IF VAL1=$(abort_flag) VAL2=1 STRATEGY=ELSE_END
- LUA_EXECUTE_LINE lua deadline:Finish()
- echo ABORT 1
- sleep sec 15
- ABORT 1
ELSE
END

