fixme: core on linux, can not found core.ini after install.

pull/32/merge
Apex Liu 2017-03-26 19:12:15 +00:00
parent 08876be3dc
commit 38c7f2ad97
10 changed files with 80 additions and 107 deletions

14
.gitignore vendored
View File

@ -49,20 +49,15 @@ __pycache__
# for dist folder
**/_tmp_
# /dist/*.zip
# /dist/*.tar.gz
/dist/windows/server/script/data
/dist/windows/client/assist/apps
/dist/windows/client/assist/cfg
/dist/server/data
/dist/client/windows/assist/apps
/dist/client/windows/assist/cfg
/server/share/etc/core.ini
/server/share/etc/web.ini
# /server/share/data/ts_db.db
/server/share/data
/server/share/log
# /server/share/data/replay
/server/www/teleport/.idea/vcs.xml
# /server/www/teleport/static/js/var.js
/server/www/packages/packages-windows/x64
@ -73,6 +68,3 @@ __pycache__
# for not finished code
/common/libex/test
/client/tp_rdp
/server/share/etc/maintenance-mode
/dist/client/windows/assist/apps
/dist/client/windows/assist/cfg

View File

@ -368,40 +368,8 @@ class InstallerWin(InstallerBase):
self._install_path = os.path.abspath(os.path.join(os.path.dirname(_exec_file), '..'))
break
# _err, _ = utils.sys_exec(r'sc query "{}"'.format(WIN_CORE_SERVICE_NAME))
# if 1060 == _err:
# # core service not install
# pass
# else:
# self._is_installed = True
# _err, _o = utils.sys_exec(r'sc qc "{}"'.format(WIN_CORE_SERVICE_NAME))
# if _err != 0:
# raise RuntimeError('Can not get core service installation information.')
# for i in _o:
# _x = i.split(':', 1)
# if 'BINARY_PATH_NAME' == _x[0].strip():
# _path = _x[1].strip()
# self._install_path = os.path.abspath(os.path.join(os.path.dirname(_path), '..'))
# break
#
# _err, _ = utils.sys_exec(r'sc query "{}"'.format(WIN_WEB_SERVICE_NAME))
# if 1060 == _err:
# # web service not install.
# pass
# else:
# self._is_installed = True
# _err, _o = utils.sys_exec(r'sc qc "{}"'.format(WIN_WEB_SERVICE_NAME))
# if _err != 0:
# raise RuntimeError('Can not get web service installation information.')
# for i in _o:
# _x = i.split(':', 1)
# if 'BINARY_PATH_NAME' == _x[0].strip():
# _path = _x[1].strip()
# self._install_path = os.path.abspath(os.path.join(os.path.dirname(_path), '..'))
# break
if self._is_installed:
cc.i('[exists]')
cc.i('[{}]'.format(self._install_path))
self._fix_path()
else:
cc.i('[not exists]')
@ -547,7 +515,7 @@ class InstallerLinux(InstallerBase):
# self._fix_path()
if self._is_installed:
cc.i('[exists]')
cc.i('[{}]'.format(self._install_path))
self._fix_path()
else:
cc.i('[not exists]')
@ -617,8 +585,9 @@ class InstallerLinux(InstallerBase):
def _start_service(self):
cc.v('')
cc.o('start services...')
utils.sys_exec('service teleport start', direct_output=True)
# raise RuntimeError('`start_service` not implement.')
_ret, _ = utils.sys_exec('service teleport start', direct_output=True)
if _ret != 0:
raise RuntimeError('not all services started.')
def _stop_service(self):
cc.o(' - stop teleport core service ... ', end='')

2
dist/server/setup.sh vendored Normal file → Executable file
View File

@ -2,7 +2,7 @@
if [ `id -u` -ne 0 ];then
echo ""
echo -e "\e[31mPlease run setup with ROOT.\033[0m"
echo -e "\e[31mPlease run setup as root.\033[0m"
echo ""
exit 1
fi

View File

@ -46,20 +46,20 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_rpc.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_crypto.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_client.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_main.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_main.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_session.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_client.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_rpc.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_db.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_main.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_http_client.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_main.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/CMakeLists.txt" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_crypto.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_web_rpc.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/main.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_env.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_env.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_db.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/main.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_session.cpp" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_web_rpc.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/core/ts_crypto.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/base_env.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/ts_membuf.h" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/tp_core/common/base_env.cpp" isTestSource="false" />

View File

@ -42,3 +42,4 @@ enabled=false
lib=telnet
bind-ip=0.0.0.0
bind-port=52389

View File

@ -21,3 +21,4 @@ log-level=1
debug=0
core-server-rpc=http://127.0.0.1:52080/rpc

View File

@ -20,36 +20,75 @@ bool TsEnv::init(bool for_web)
if (!for_web)
return true;
// 定位 log, etc, www 路径
// 默认情况下,以上三个目录均位于本可执行程序的 ../ 相对位置,
// 如果不存在则可能是开发调试模式则尝试从源代码仓库根目录下的share目录中查找。
// check development flag file, if exists, run in development mode for trace and debug.
ex_wstr dev_flag_file = m_exec_path;
ex_path_join(dev_flag_file, false, L"dev_mode", NULL);
ex_wstr base_path = m_exec_path;
ex_path_join(base_path, true, L"..", NULL);
ex_wstr log_path;
ex_wstr conf_file;
ex_wstr conf_file = base_path;
ex_path_join(conf_file, false, L"etc", L"web.ini", NULL);
if (ex_is_file_exists(conf_file.c_str()))
{
m_www_path = base_path;
ex_path_join(m_www_path, false, L"www", NULL);
}
else
if (ex_is_file_exists(dev_flag_file.c_str()))
{
EXLOGW("===== DEVELOPMENT MODE =====\n");
base_path = m_exec_path;
ex_path_join(base_path, true, L"..", L"..", L"..", L"..", L"server", L"share", NULL);
ex_path_join(base_path, true, L"..", L"..", L"..", L"..", L"server", NULL);
conf_file = base_path;
ex_path_join(conf_file, false, L"share", L"etc", L"web.ini.in", NULL);
log_path = base_path;
ex_path_join(log_path, false, L"share", L"log", NULL);
}
else // not in development mode
{
base_path = m_exec_path;
ex_path_join(base_path, true, L"..", NULL);
#ifdef EX_OS_WIN
conf_file = base_path;
ex_path_join(conf_file, false, L"etc", L"web.ini", NULL);
log_path = base_path;
ex_path_join(log_path, false, L"log", NULL);
#else
conf_file = L"/etc/teleport/web.ini";
log_path = L"/var/log/teleport";
m_www_path = m_exec_path;
ex_path_join(m_www_path, true, L"..", L"..", L"..", L"..", L"server", L"www", NULL);
#endif
}
m_www_path = base_path;
ex_path_join(m_www_path, false, L"www", NULL);
// // 定位 log, etc, www 路径
// // 默认情况下,以上三个目录均位于本可执行程序的 ../ 相对位置,
// // 如果不存在则可能是开发调试模式则尝试从源代码仓库根目录下的share目录中查找。
// ex_wstr base_path = m_exec_path;
// ex_path_join(base_path, true, L"..", NULL);
//
// ex_wstr conf_file = base_path;
// ex_path_join(conf_file, false, L"etc", L"web.ini", NULL);
//
// if (ex_is_file_exists(conf_file.c_str()))
// {
// m_www_path = base_path;
// ex_path_join(m_www_path, false, L"www", NULL);
// }
// else
// {
// EXLOGW("===== DEVELOPMENT MODE =====\n");
// base_path = m_exec_path;
// ex_path_join(base_path, true, L"..", L"..", L"..", L"..", L"server", L"share", NULL);
//
// conf_file = base_path;
// ex_path_join(conf_file, false, L"etc", L"web.ini", NULL);
//
// m_www_path = m_exec_path;
// ex_path_join(m_www_path, true, L"..", L"..", L"..", L"..", L"server", L"www", NULL);
// }
if (!ex_is_file_exists(conf_file.c_str()))
{
EXLOGE("[tpweb] web.conf not found.\n");
EXLOGE("[tpweb] web.ini not found.\n");
return false;
}
@ -64,8 +103,8 @@ bool TsEnv::init(bool for_web)
ExIniSection* ps = cfg.GetDumySection();
if (!ps->GetStr(L"log_file", log_file))
{
ex_wstr log_path = base_path;
ex_path_join(log_path, false, L"log", NULL);
// ex_wstr log_path = base_path;
// ex_path_join(log_path, false, L"log", NULL);
EXLOG_FILE(L"tpweb.log", log_path.c_str());
}
else
@ -76,7 +115,8 @@ bool TsEnv::init(bool for_web)
if (log_file[ log_file.length() - 1 ] == L'"' || log_file[log_file.length() - 1] == L'\'')
log_file.erase(log_file.length() - 1, 1);
ex_wstr log_path = log_file;
// ex_wstr log_path = log_file;
log_path = log_file;
ex_dirname(log_path);
ex_wstr file_name;
file_name.assign(log_file, log_path.length() + 1, log_file.length());

View File

@ -14,9 +14,6 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">
<option name="myDocStringFormat" value="Epytext" />
</component>
<component name="TemplatesService">
<option name="templateFileTypes">
<list>

View File

@ -38,12 +38,6 @@ class WebServerCore:
cfg.res_path = os.path.abspath(options['res_path'])
cfg.cfg_path = os.path.abspath(options['cfg_path'])
# cfg.app_mode = APP_MODE_NORMAL
# if os.path.exists(os.path.join(cfg.cfg_path, 'maintenance-mode')):
# cfg.app_mode = APP_MODE_MAINTENANCE
# else:
# cfg.app_mode = APP_MODE_NORMAL
_cfg_file = os.path.join(cfg.cfg_path, 'web.ini')
if not cfg.load_web(_cfg_file):
return False

View File

@ -28,15 +28,10 @@ for p in sys.path:
for p in x:
sys.path.remove(p)
is_dev_mode = False
path_of_this_file = os.path.abspath(os.path.dirname(__file__))
PATH_APP_ROOT = os.path.abspath(os.path.join(path_of_this_file, '..'))
# 根据源代码目录形式,检查是否是开发版本
if os.path.exists(os.path.join(PATH_APP_ROOT, '..', '..', 'share', 'etc')):
is_dev_mode = True
# 检查操作系统目前仅支持Win和Linux
PLATFORM = platform.system().lower()
if PLATFORM not in ['windows', 'linux', 'darwin']:
@ -57,29 +52,13 @@ if _ext_path not in sys.path:
sys.path.append(_ext_path)
# 确定一些路径
if is_dev_mode:
if os.path.exists(os.path.join(os.path.dirname(sys.executable), 'dev_mode')):
# 开发调试模式
# _ext_path = os.path.abspath(os.path.join(PATH_APP_ROOT, '..', 'packages', 'packages-common'))
# if _ext_path not in sys.path:
# sys.path.append(_ext_path)
#
# _ext_path = os.path.abspath(os.path.join(PATH_APP_ROOT, '..', 'packages', 'packages-{}'.format(PLATFORM), BITS))
# if _ext_path not in sys.path:
# sys.path.append(_ext_path)
#
PATH_LOG = os.path.abspath(os.path.join(PATH_APP_ROOT, '..', '..', 'share', 'log'))
PATH_CONF = os.path.abspath(os.path.join(PATH_APP_ROOT, '..', '..', 'share', 'etc'))
PATH_DATA = os.path.abspath(os.path.join(PATH_APP_ROOT, '..', '..', 'share', 'data'))
else:
# _ext_path = os.path.abspath(os.path.join(PATH_APP_ROOT, '..', 'packages', 'packages-common'))
# if _ext_path not in sys.path:
# sys.path.append(_ext_path)
#
# _ext_path = os.path.abspath(os.path.join(PATH_APP_ROOT, '..', 'packages', 'packages-{}'.format(PLATFORM), BITS))
# if _ext_path not in sys.path:
# sys.path.append(_ext_path)
#
PATH_LOG = os.path.abspath(os.path.join(PATH_APP_ROOT, '..', '..', 'log'))
PATH_CONF = os.path.abspath(os.path.join(PATH_APP_ROOT, '..', '..', 'etc'))
PATH_DATA = os.path.abspath(os.path.join(PATH_APP_ROOT, '..', '..', 'data'))