diff --git a/README-CN.md b/README-CN.md index 0b7e42d4fa19045e94f004ab61159a8d79e4bb82..907e87347db7de03966df8375ef2b3cca447ccef 100644 --- a/README-CN.md +++ b/README-CN.md @@ -104,6 +104,12 @@ sudo yum install -y zlib-devel xz-devel snappy-devel jansson jansson-devel pkgco sudo yum config-manager --set-enabled Powertools ``` +### MacOS + +``` +sudo brew install argp-standalone pkgconfig +``` + ### 设置 golang 开发环境 TDengine 包含数个使用 Go 语言开发的组件,比如taosAdapter, 请参考 golang.org 官方文档设置 go 开发环境。 @@ -210,14 +216,14 @@ cmake .. -G "NMake Makefiles" nmake ``` - +``` # 安装 @@ -263,6 +269,24 @@ nmake install sudo make install ``` +用户可以在[文件目录结构](https://docs.taosdata.com/reference/directory/)中了解更多在操作系统中生成的目录或文件。 + +从源代码安装也会为 TDengine 配置服务管理 ,用户也可以选择[从安装包中安装](https://docs.taosdata.com/get-started/package/)。 + +安装成功后,可以在应用程序中双击 TDengine 图标启动服务,或者在终端中启动 TDengine 服务: + +```bash +launchctl start taosd +``` + +用户可以使用 TDengine CLI 来连接 TDengine 服务,在终端中,输入: + +```bash +taos +``` + +如果 TDengine CLI 连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印出错误消息。 + ## 快速运行 如果不希望以服务方式运行 TDengine,也可以在终端中直接运行它。也即在生成完成后,执行以下命令(在 Windows 下,生成的可执行文件会带有 .exe 后缀,例如会名为 taosd.exe ): diff --git a/README.md b/README.md index fe9bb49ed8d70afb7b1f3a84933efd62b672229e..69d7cc13ad098333249f808c3ea75c4321048cdb 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,12 @@ If the PowerTools installation fails, you can try to use: sudo yum config-manager --set-enabled powertools ``` +### MacOS + +``` +sudo brew install argp-standalone pkgconfig +``` + ### Setup golang environment TDengine includes a few components like taosAdapter developed by Go language. Please refer to golang.org official documentation for golang environment setup. @@ -213,14 +219,14 @@ cmake .. -G "NMake Makefiles" nmake ``` - +``` # Installing @@ -258,7 +264,7 @@ After building successfully, TDengine can be installed by: nmake install ``` - + +Users can find more information about directories installed on the system in the [directory and files](https://docs.tdengine.com/reference/directory/) section. + +Installing from source code will also configure service management for TDengine.Users can also choose to [install from packages](https://docs.tdengine.com/get-started/package/) for it. + +To start the service after installation, double-click the /applications/TDengine to start the program, or in a terminal, use: + +```bash +launchctl start taosd +``` + +Then users can use the TDengine CLI to connect the TDengine server. In a terminal, use: + +```bash +taos +``` + +If TDengine CLI connects the server successfully, welcome messages and version info are printed. Otherwise, an error message is shown. ## Quick Run diff --git a/docs/en/05-get-started/03-package.md b/docs/en/05-get-started/03-package.md index 25a92573faa6d6b3a9625f161bc7d0258492b91a..328e43c4f784566235742b35e81446bcecd92b4b 100644 --- a/docs/en/05-get-started/03-package.md +++ b/docs/en/05-get-started/03-package.md @@ -111,6 +111,13 @@ Note: TDengine only supports Windows Server 2016/2019 and Windows 10/11 on the W 2. Run the downloaded package to install TDengine. + + + +1. Download the Mac installation package. + +2. Run the downloaded package to install TDengine. + @@ -178,6 +185,12 @@ The following `systemctl` commands can help you manage TDengine service: After the installation is complete, run `C:\TDengine\taosd.exe` to start TDengine Server. + + + + +After the installation is complete, double-click the /applications/TDengine to start the program, or run `launchctl start taosd` to start TDengine Server. + diff --git a/docs/zh/05-get-started/03-package.md b/docs/zh/05-get-started/03-package.md index 2c857d37f3a8591316949f9a7440a115740a8e2d..cec430accf416509a59199f22e098ed5e6f4277b 100644 --- a/docs/zh/05-get-started/03-package.md +++ b/docs/zh/05-get-started/03-package.md @@ -110,6 +110,13 @@ apt-get 方式只适用于 Debian 或 Ubuntu 系统。 2. 运行可执行程序来安装 TDengine。 + + + +1. 从列表中下载获得 pkg 安装程序; + +2. 运行可执行程序来安装 TDengine。 + @@ -177,6 +184,12 @@ Active: inactive (dead) 安装后,在 `C:\TDengine` 目录下,运行 `taosd.exe` 来启动 TDengine 服务进程。 + + + + +安装后,在应用程序目录下,双击 TDengine 来启动程序,也可以运行 `launchctl start taosd` 来启动 TDengine 服务进程。 + diff --git a/include/os/osDir.h b/include/os/osDir.h index 95b1a6ee1d00ab18e31522063102ff0ec9a2bab8..2bdc99d2687d23a826e3430ed2c69e96e5619d24 100644 --- a/include/os/osDir.h +++ b/include/os/osDir.h @@ -38,9 +38,9 @@ extern "C" { #define TD_LOG_DIR_PATH "C:\\TDengine\\log\\" #elif defined(_TD_DARWIN_64) #define TD_TMP_DIR_PATH "/tmp/taosd/" -#define TD_CFG_DIR_PATH "/usr/local/etc/taos/" -#define TD_DATA_DIR_PATH "/usr/local/var/lib/taos/" -#define TD_LOG_DIR_PATH "/usr/local/var/log/taos/" +#define TD_CFG_DIR_PATH "/etc/taos/" +#define TD_DATA_DIR_PATH "/var/lib/taos/" +#define TD_LOG_DIR_PATH "/var/log/taos/" #else #define TD_TMP_DIR_PATH "/tmp/" #define TD_CFG_DIR_PATH "/etc/taos/" diff --git a/packaging/tools/TDengine b/packaging/tools/TDengine new file mode 100755 index 0000000000000000000000000000000000000000..3025a5639f3dda2c9b06ef5ffaf0a7f0995c2532 --- /dev/null +++ b/packaging/tools/TDengine @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + + +function showAlertMessage(){ +osascript < + + + + Label + taosd + ProgramArguments + + /usr/local/bin/taosd + + ProcessType + Interactive + Disabled + + RunAtLoad + + LaunchOnlyOnce + + SessionCreate + + ExitTimeOut + 600 + KeepAlive + + SuccessfulExit + + AfterInitialDemand + + + Program + /usr/local/bin/taosd + + \ No newline at end of file diff --git a/packaging/tools/logo.png b/packaging/tools/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..e739e5dd8c4b01b93e8c98606def3ae9adae257b Binary files /dev/null and b/packaging/tools/logo.png differ diff --git a/packaging/tools/mac_before_install.txt b/packaging/tools/mac_before_install.txt new file mode 100644 index 0000000000000000000000000000000000000000..f70ea7161f4df28594639f8f2a1f0a335b8ad03f --- /dev/null +++ b/packaging/tools/mac_before_install.txt @@ -0,0 +1,5 @@ +TDengine is a high-efficient, scalable, high-available distributed time-series database, which makes a lot of optimizations on inserting and querying data, which is far more efficient than normal regular databases. So TDengine can meet the high requirements of IOT and other areas on storing and querying a large amount of data. + +To configure TDengine : edit /etc/taos/taos.cfg +To start service : launchctl start taosd +To access TDengine : use taos in shell \ No newline at end of file diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 58b43850013a27147e76c0eb7a6e4c9a219b3303..a71614ad6e10b2c745a50288481ff09b014bf3d0 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -30,36 +30,31 @@ productName="TDengine" emailName="taosdata.com" uninstallScript="rmtaos" -if [ "$osType" != "Darwin" ]; then - data_dir=${dataDir} - log_dir=${logDir} - - cfg_install_dir=${configDir} +data_dir=${dataDir} +log_dir=${logDir} +cfg_install_dir=${configDir} +if [ "$osType" != "Darwin" ]; then bin_link_dir="/usr/bin" lib_link_dir="/usr/lib" lib64_link_dir="/usr/lib64" inc_link_dir="/usr/include" - - install_main_dir=${installDir} - - bin_dir="${installDir}/bin" else - data_dir="/usr/local${dataDir}" - log_dir="/usr/local${logDir}" - - cfg_install_dir="/usr/local${configDir}" - bin_link_dir="/usr/local/bin" lib_link_dir="/usr/local/lib" inc_link_dir="/usr/local/include" - install_main_dir="/usr/local/Cellar/tdengine/${verNumber}" - install_main_2_dir="/usr/local/Cellar/tdengine@${verNumber}/${verNumber}" - - bin_dir="/usr/local/Cellar/tdengine/${verNumber}/bin" - bin_2_dir="/usr/local/Cellar/tdengine@${verNumber}/${verNumber}/bin" + if [ -d "/usr/local/Cellar/" ];then + installDir="/usr/local/Cellar/tdengine/${verNumber}" + elif [ -d "/opt/homebrew/Cellar/" ];then + installDir="/opt/homebrew/Cellar/tdengine/${verNumber}" + else + installDir="/usr/local/taos" + fi fi +install_main_dir=${installDir} +bin_dir="${installDir}/bin" +cfg_dir="${installDir}/cfg" service_config_dir="/etc/systemd/system" @@ -71,14 +66,16 @@ GREEN_UNDERLINE='\033[4;32m' NC='\033[0m' csudo="" +csudouser="" +if command -v sudo >/dev/null; then + csudo="sudo " + csudouser="sudo -u ${USER} " +fi service_mod=2 os_type=0 if [ "$osType" != "Darwin" ]; then - if command -v sudo >/dev/null; then - csudo="sudo " - fi initd_mod=0 if pidof systemd &>/dev/null; then service_mod=0 @@ -142,28 +139,16 @@ function kill_taosd() { function install_main_path() { #create install main dir and all sub dir - if [ "$osType" != "Darwin" ]; then - ${csudo}rm -rf ${install_main_dir} || : - ${csudo}mkdir -p ${install_main_dir} - ${csudo}mkdir -p ${install_main_dir}/cfg - ${csudo}mkdir -p ${install_main_dir}/bin - # ${csudo}mkdir -p ${install_main_dir}/connector - ${csudo}mkdir -p ${install_main_dir}/driver - ${csudo}mkdir -p ${install_main_dir}/examples - ${csudo}mkdir -p ${install_main_dir}/include - ${csudo}mkdir -p ${install_main_dir}/share - # ${csudo}mkdir -p ${install_main_dir}/init.d - else - ${csudo}rm -rf ${install_main_dir} || ${csudo}rm -rf ${install_main_2_dir} || : - ${csudo}mkdir -p ${install_main_dir} || ${csudo}mkdir -p ${install_main_2_dir} - ${csudo}mkdir -p ${install_main_dir}/cfg || ${csudo}mkdir -p ${install_main_2_dir}/cfg - ${csudo}mkdir -p ${install_main_dir}/bin || ${csudo}mkdir -p ${install_main_2_dir}/bin - # ${csudo}mkdir -p ${install_main_dir}/connector || ${csudo}mkdir -p ${install_main_2_dir}/connector - ${csudo}mkdir -p ${install_main_dir}/driver || ${csudo}mkdir -p ${install_main_2_dir}/driver - ${csudo}mkdir -p ${install_main_dir}/examples || ${csudo}mkdir -p ${install_main_2_dir}/examples - ${csudo}mkdir -p ${install_main_dir}/include || ${csudo}mkdir -p ${install_main_2_dir}/include - ${csudo}mkdir -p ${install_main_dir}/share || ${csudo}mkdir -p ${install_main_2_dir}/share - fi + ${csudo}rm -rf ${install_main_dir} || : + ${csudo}mkdir -p ${install_main_dir} + ${csudo}mkdir -p ${install_main_dir}/cfg + ${csudo}mkdir -p ${install_main_dir}/bin + # ${csudo}mkdir -p ${install_main_dir}/connector + ${csudo}mkdir -p ${install_main_dir}/driver + ${csudo}mkdir -p ${install_main_dir}/examples + ${csudo}mkdir -p ${install_main_dir}/include + ${csudo}mkdir -p ${install_main_dir}/share + # ${csudo}mkdir -p ${install_main_dir}/init.d } function install_bin() { @@ -175,11 +160,11 @@ function install_bin() { ${csudo}rm -f ${bin_link_dir}/taosdemo || : ${csudo}rm -f ${bin_link_dir}/taosdump || : ${csudo}rm -f ${bin_link_dir}/taosx || : + ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : if [ "$osType" != "Darwin" ]; then ${csudo}rm -f ${bin_link_dir}/perfMonitor || : ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : ${csudo}cp -r ${binary_dir}/build/bin/${clientName} ${install_main_dir}/bin || : [ -f ${binary_dir}/build/bin/taosBenchmark ] && ${csudo}cp -r ${binary_dir}/build/bin/taosBenchmark ${install_main_dir}/bin || : @@ -209,18 +194,26 @@ function install_bin() { [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : else - ${csudo}cp -r ${binary_dir}/build/bin/* ${install_main_dir}/bin || ${csudo}cp -r ${binary_dir}/build/bin/* ${install_main_2_dir}/bin || : - ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_2_dir} || : - ${csudo}cp -r ${script_dir}/remove_client.sh ${install_main_dir}/bin || ${csudo}cp -r ${script_dir}/remove_client.sh ${install_main_2_dir}/bin || : - ${csudo}chmod 0555 ${install_main_dir}/bin/* || ${csudo}chmod 0555 ${install_main_2_dir}/bin/* + ${csudo}cp -r ${binary_dir}/build/bin/${clientName} ${install_main_dir}/bin || : + [ -f ${binary_dir}/build/bin/taosBenchmark ] && ${csudo}cp -r ${binary_dir}/build/bin/taosBenchmark ${install_main_dir}/bin || : + [ -f ${install_main_dir}/bin/taosBenchmark ] && ${csudo}ln -sf ${install_main_dir}/bin/taosBenchmark ${install_main_dir}/bin/taosdemo || : + [ -f ${binary_dir}/build/bin/taosdump ] && ${csudo}cp -r ${binary_dir}/build/bin/taosdump ${install_main_dir}/bin || : + [ -f ${binary_dir}/build/bin/taosadapter ] && ${csudo}cp -r ${binary_dir}/build/bin/taosadapter ${install_main_dir}/bin || : + [ -f ${binary_dir}/build/bin/udfd ] && ${csudo}cp -r ${binary_dir}/build/bin/udfd ${install_main_dir}/bin || : + [ -f ${binary_dir}/build/bin/taosx ] && ${csudo}cp -r ${binary_dir}/build/bin/taosx ${install_main_dir}/bin || : + ${csudo}cp -r ${binary_dir}/build/bin/${serverName} ${install_main_dir}/bin || : + + ${csudo}cp -r ${script_dir}/remove.sh ${install_main_dir}/bin || : + ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/${clientName} ] || [ -x ${install_main_2_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || ${csudo}ln -s ${install_main_2_dir}/bin/${clientName} || : - [ -x ${install_main_dir}/bin/${serverName} ] || [ -x ${install_main_2_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || ${csudo}ln -s ${install_main_2_dir}/bin/${serverName} || : - [ -x ${install_main_dir}/bin/taosadapter ] || [ -x ${install_main_2_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || ${csudo}ln -s ${install_main_2_dir}/bin/taosadapter || : - [ -x ${install_main_dir}/bin/udfd ] || [ -x ${install_main_2_dir}/bin/udfd ] && ${csudo}ln -s ${install_main_dir}/bin/udfd ${bin_link_dir}/udfd || ${csudo}ln -s ${install_main_2_dir}/bin/udfd || : - [ -x ${install_main_dir}/bin/taosdump ] || [ -x ${install_main_2_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || ln -s ${install_main_2_dir}/bin/taosdump ${bin_link_dir}/taosdump || : - [ -x ${install_main_dir}/bin/taosdemo ] || [ -x ${install_main_2_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || ln -s ${install_main_2_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : - [ -x ${install_main_dir}/bin/taosx ] || [ -x ${install_main_2_dir}/bin/taosx ] && ${csudo}ln -s ${install_main_dir}/bin/taosx ${bin_link_dir}/taosx || ln -s ${install_main_2_dir}/bin/taosx ${bin_link_dir}/taosx || : + [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || : + [ -x ${install_main_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || : + [ -x ${install_main_dir}/bin/taosadapter ] && ${csudo}ln -s ${install_main_dir}/bin/taosadapter ${bin_link_dir}/taosadapter || : + [ -x ${install_main_dir}/bin/udfd ] && ${csudo}ln -s ${install_main_dir}/bin/udfd ${bin_link_dir}/udfd || : + [ -x ${install_main_dir}/bin/taosdump ] && ${csudo}ln -s ${install_main_dir}/bin/taosdump ${bin_link_dir}/taosdump || : + [ -f ${install_main_dir}/bin/taosBenchmark ] && ${csudo}ln -sf ${install_main_dir}/bin/taosBenchmark ${install_main_dir}/bin/taosdemo || : + [ -x ${install_main_dir}/bin/taosx ] && ${csudo}ln -s ${install_main_dir}/bin/taosx ${bin_link_dir}/taosx || : + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : fi } @@ -331,28 +324,20 @@ function install_lib() { fi else ${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \ - ${install_main_dir}/driver || - ${csudo}cp -Rf ${binary_dir}/build/lib/libtaos.${verNumber}.dylib \ - ${install_main_2_dir}/driver && - ${csudo}chmod 777 ${install_main_dir}/driver/* || - ${csudo}chmod 777 ${install_main_2_dir}/driver/* - - ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* \ - ${install_main_dir}/driver/libtaos.1.dylib || - ${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.* \ - ${install_main_2_dir}/driver/libtaos.1.dylib || : - - ${csudo}ln -sf ${install_main_dir}/driver/libtaos.1.dylib \ - ${install_main_dir}/driver/libtaos.dylib || - ${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.1.dylib \ - ${install_main_2_dir}/driver/libtaos.dylib || : + ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* ${csudo}ln -sf ${install_main_dir}/driver/libtaos.${verNumber}.dylib \ - ${lib_link_dir}/libtaos.1.dylib || - ${csudo}ln -sf ${install_main_2_dir}/driver/libtaos.${verNumber}.dylib \ - ${lib_link_dir}/libtaos.1.dylib || : + ${lib_link_dir}/libtaos.1.dylib || : ${csudo}ln -sf ${lib_link_dir}/libtaos.1.dylib ${lib_link_dir}/libtaos.dylib || : + + if [ -f ${binary_dir}/build/lib/libtaosws.dylib ]; then + ${csudo}cp ${binary_dir}/build/lib/libtaosws.dylib \ + ${install_main_dir}/driver && + ${csudo}chmod 777 ${install_main_dir}/driver/libtaosws.dylib ||: + + ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.dylib ${lib_link_dir}/libtaosws.dylib || : + fi fi install_jemalloc @@ -365,37 +350,30 @@ function install_lib() { } function install_header() { + ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : + [ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h ||: + ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h ${source_dir}/include/libs/function/taosudf.h \ + ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* - if [ "$osType" != "Darwin" ]; then - ${csudo}rm -f ${inc_link_dir}/taos.h ${inc_link_dir}/taosdef.h ${inc_link_dir}/taoserror.h ${inc_link_dir}/taosudf.h || : - [ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h ||: - ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h ${source_dir}/include/libs/function/taosudf.h \ - ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* - - if [ -f ${binary_dir}/build/include/taosws.h ]; then - ${csudo}cp -f ${binary_dir}/build/include/taosws.h ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/taosws.h ||: - ${csudo}ln -sf ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h ||: - fi + if [ -f ${binary_dir}/build/include/taosws.h ]; then + ${csudo}cp -f ${binary_dir}/build/include/taosws.h ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/taosws.h ||: + ${csudo}ln -sf ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h ||: + fi - ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h - ${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h + ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h - else - ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h ${source_dir}/include/libs/function/taosudf.h \ - ${install_main_dir}/include || - ${csudo}cp -f ${source_dir}/include/client/taos.h ${source_dir}/include/common/taosdef.h ${source_dir}/include/util/taoserror.h ${source_dir}/include/libs/function/taosudf.h \ - ${install_main_2_dir}/include && - ${csudo}chmod 644 ${install_main_dir}/include/* || ${csudo}chmod 644 ${install_main_2_dir}/include/* - fi + ${csudo}chmod 644 ${install_main_dir}/include/* } function install_config() { if [ ! -f ${cfg_install_dir}/${configFile} ]; then ${csudo}mkdir -p ${cfg_install_dir} [ -f ${script_dir}/../cfg/${configFile} ] && - ${csudo}cp ${script_dir}/../cfg/${configFile} ${cfg_install_dir} + ${csudo}cp ${script_dir}/../cfg/${configFile} ${cfg_install_dir} && + ${csudo}cp ${script_dir}/../cfg/${configFile} ${cfg_dir} ${csudo}chmod 644 ${cfg_install_dir}/${configFile} ${csudo}cp -f ${script_dir}/../cfg/${configFile} \ ${cfg_install_dir}/${configFile}.${verNumber} @@ -404,6 +382,7 @@ function install_config() { else ${csudo}cp -f ${script_dir}/../cfg/${configFile} \ ${cfg_install_dir}/${configFile}.${verNumber} + ${csudo}cp -f ${script_dir}/../cfg/${configFile} ${cfg_dir} fi } @@ -411,7 +390,8 @@ function install_taosadapter_config() { if [ ! -f "${cfg_install_dir}/taosadapter.toml" ]; then ${csudo}mkdir -p ${cfg_install_dir} || : [ -f ${binary_dir}/test/cfg/taosadapter.toml ] && - ${csudo}cp ${binary_dir}/test/cfg/taosadapter.toml ${cfg_install_dir} || : + ${csudo}cp ${binary_dir}/test/cfg/taosadapter.toml ${cfg_install_dir} && + ${csudo}cp ${binary_dir}/test/cfg/taosadapter.toml ${cfg_dir} || : [ -f ${cfg_install_dir}/taosadapter.toml ] && ${csudo}chmod 644 ${cfg_install_dir}/taosadapter.toml || : [ -f ${binary_dir}/test/cfg/taosadapter.toml ] && @@ -424,6 +404,7 @@ function install_taosadapter_config() { if [ -f "${binary_dir}/test/cfg/taosadapter.toml" ]; then ${csudo}cp -f ${binary_dir}/test/cfg/taosadapter.toml \ ${cfg_install_dir}/taosadapter.toml.${verNumber} || : + ${csudo}cp -f ${binary_dir}/test/cfg/taosadapter.toml ${cfg_dir} || : fi fi } @@ -431,20 +412,12 @@ function install_taosadapter_config() { function install_log() { ${csudo}rm -rf ${log_dir} || : ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - if [ "$osType" != "Darwin" ]; then - ${csudo}ln -s ${log_dir} ${install_main_dir}/log - else - ${csudo}ln -s ${log_dir} ${install_main_dir}/log || ${csudo}ln -s ${log_dir} ${install_main_2_dir}/log - fi + ${csudo}ln -s ${log_dir} ${install_main_dir}/log } function install_data() { - ${csudo}mkdir -p ${data_dir} - if [ "$osType" != "Darwin" ]; then - ${csudo}ln -s ${data_dir} ${install_main_dir}/data - else - ${csudo}ln -s ${data_dir} ${install_main_dir}/data || ${csudo}ln -s ${data_dir} ${install_main_2_dir}/data - fi + ${csudo}mkdir -p ${data_dir} && ${csudo}chmod 777 ${data_dir} + ${csudo}ln -s ${data_dir} ${install_main_dir}/data } function install_connector() { @@ -453,31 +426,17 @@ function install_connector() { else echo "WARNING: go connector not found, please check if want to use it!" fi - if [ "$osType" != "Darwin" ]; then - ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector || : - ${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &>/dev/null && ${csudo}chmod 777 ${install_main_dir}/connector/*.jar || echo &>/dev/null || : - else - ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector || ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_2_dir}/connector || : - ${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &>/dev/null && ${csudo}chmod 777 ${install_main_dir}/connector/*.jar || echo &>/dev/null || : - ${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_2_dir}/connector &>/dev/null && ${csudo}chmod 777 ${install_main_2_dir}/connector/*.jar || echo &>/dev/null || : - fi + ${csudo}cp -rf ${source_dir}/src/connector/python ${install_main_dir}/connector || : + ${csudo}cp ${binary_dir}/build/lib/*.jar ${install_main_dir}/connector &>/dev/null && ${csudo}chmod 777 ${install_main_dir}/connector/*.jar || echo &>/dev/null || : } function install_examples() { - if [ "$osType" != "Darwin" ]; then - ${csudo}cp -rf ${source_dir}/examples/* ${install_main_dir}/examples || : - else - ${csudo}cp -rf ${source_dir}/examples/* ${install_main_dir}/examples || ${csudo}cp -rf ${source_dir}/examples/* ${install_main_2_dir}/examples || : - fi + ${csudo}cp -rf ${source_dir}/examples/* ${install_main_dir}/examples || : } function install_web() { if [ -d "${binary_dir}/build/share" ]; then - if [ "$osType" != "Darwin" ]; then - ${csudo}cp -rf ${binary_dir}/build/share/* ${install_main_dir}/share || : - else - ${csudo}cp -rf ${binary_dir}/build/share/* ${install_main_dir}/share || ${csudo}cp -rf ${binary_dir}/build/share/* ${install_main_2_dir}/share || : - fi + ${csudo}cp -rf ${binary_dir}/build/share/* ${install_main_dir}/share || : fi } @@ -575,13 +534,36 @@ function install_taosadapter_service() { fi } +function install_service_on_launchctl() { + ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : + ${csudo}cp ${script_dir}/com.taosdata.taosd.plist /Library/LaunchDaemons/com.taosdata.taosd.plist + ${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosd.plist || : +} + function install_service() { - if ((${service_mod} == 0)); then - install_service_on_systemd - elif ((${service_mod} == 1)); then - install_service_on_sysvinit + if [ "$osType" != "Darwin" ]; then + if ((${service_mod} == 0)); then + install_service_on_systemd + elif ((${service_mod} == 1)); then + install_service_on_sysvinit + else + kill_taosd + fi else - kill_taosd + install_service_on_launchctl + fi +} +function install_app() { + if [ "$osType" = "Darwin" ]; then + ${csudo}rm -rf /Applications/TDengine.app && + ${csudo}mkdir -p /Applications/TDengine.app/Contents/MacOS/ && + ${csudo}cp ${script_dir}/TDengine /Applications/TDengine.app/Contents/MacOS/ && + echo "" | ${csudo}tee /Applications/TDengine.app/Contents/Info.plist > /dev/null && + ${csudo}sips -i ${script_dir}/logo.png > /dev/null && + DeRez -only icns ${script_dir}/logo.png | ${csudo}tee /Applications/TDengine.app/mac_logo.rsrc > /dev/null && + ${csudo}rez -append /Applications/TDengine.app/mac_logo.rsrc -o $'/Applications/TDengine.app/Icon\r' && + ${csudo}SetFile -a C /Applications/TDengine.app/ && + ${csudo}rm /Applications/TDengine.app/mac_logo.rsrc fi } @@ -610,6 +592,7 @@ function update_TDengine() { install_examples install_web install_bin + install_app install_service install_taosadapter_service @@ -633,7 +616,11 @@ function update_TDengine() { [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: ${csudo}service taosadapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}" + if [ "$osType" != "Darwin" ]; then + echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}" + else + echo -e "${GREEN_DARK}To start service ${NC}: launchctl start ${serverName}${NC}" + fi [ -f ${installDir}/bin/taosadapter ] && \ echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}" fi @@ -656,6 +643,7 @@ function install_TDengine() { # install_connector install_examples install_bin + install_app install_service install_taosadapter_service @@ -679,7 +667,11 @@ function install_TDengine() { [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: ${csudo}service taosadapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName} ${NC}: ./${serverName}${NC}" + if [ "$osType" != "Darwin" ]; then + echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}" + else + echo -e "${GREEN_DARK}To start service ${NC}: launchctl start ${serverName}${NC}" + fi [ -f ${installDir}/bin/taosadapter ] && \ echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}" fi @@ -694,14 +686,8 @@ echo source directory: $1 echo binary directory: $2 if [ -x ${data_dir}/dnode/dnodeCfg.json ]; then echo -e "\033[44;31;5mThe default data directory ${data_dir} contains old data of tdengine 2.x, please clear it before installing!\033[0m" -elif [ "$osType" != "Darwin" ]; then - if [ -x ${bin_dir}/${clientName} ]; then - update_TDengine - else - install_TDengine - fi else - if [ -x ${bin_dir}/${clientName} ] || [ -x ${bin_2_dir}/${clientName} ]; then + if [ -x ${bin_dir}/${clientName} ]; then update_TDengine else install_TDengine diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index fcc8a2a942931539b1c2f068f14f074479cbfe08..29d4ac017ca9d8813e1f7c69f4f5e6056602b16c 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -7,27 +7,52 @@ iplist="" serverFqdn="" -# -----------------------Variables definition--------------------- -script_dir=$(dirname $(readlink -f "$0")) +osType=`uname` + # Dynamic directory data_dir="/var/lib/taos" log_dir="/var/log/taos" -data_link_dir="/usr/local/taos/data" -log_link_dir="/usr/local/taos/log" -install_main_dir="/usr/local/taos" +cfg_install_dir="/etc/taos" -# static directory -cfg_dir="/usr/local/taos/cfg" -bin_dir="/usr/local/taos/bin" -lib_dir="/usr/local/taos/driver" -init_d_dir="/usr/local/taos/init.d" -inc_dir="/usr/local/taos/include" +if [ "$osType" != "Darwin" ]; then + script_dir=$(dirname $(readlink -f "$0")) + verNumber="" + lib_file_ext="so" + + bin_link_dir="/usr/bin" + lib_link_dir="/usr/lib" + lib64_link_dir="/usr/lib64" + inc_link_dir="/usr/include" + + install_main_dir="/usr/local/taos" +else + script_dir=${source_dir}/packaging/tools + verNumber=`ls tdengine/driver | grep -E "libtaos\.[0-9]\.[0-9]" | sed "s/libtaos.//g" | sed "s/.dylib//g" | head -n 1` + lib_file_ext="dylib" + + bin_link_dir="/usr/local/bin" + lib_link_dir="/usr/local/lib" + lib64_link_dir="/usr/local/lib" + inc_link_dir="/usr/local/include" + + if [ -d "/usr/local/Cellar/" ];then + install_main_dir="/usr/local/Cellar/tdengine/${verNumber}" + elif [ -d "/opt/homebrew/Cellar/" ];then + install_main_dir="/opt/homebrew/Cellar/tdengine/${verNumber}" + else + install_main_dir="/usr/local/taos" + fi +fi -cfg_install_dir="/etc/taos" -bin_link_dir="/usr/bin" -lib_link_dir="/usr/lib" -lib64_link_dir="/usr/lib64" -inc_link_dir="/usr/include" +data_link_dir="${install_main_dir}/data" +log_link_dir="${install_main_dir}/log" + +# static directory +cfg_dir="${install_main_dir}/cfg" +bin_dir="${install_main_dir}/bin" +lib_dir="${install_main_dir}/driver" +init_d_dir="${install_main_dir}/init.d" +inc_dir="${install_main_dir}/include" service_config_dir="/etc/systemd/system" @@ -40,8 +65,10 @@ GREEN_UNDERLINE='\033[4;32m' NC='\033[0m' csudo="" +csudouser="" if command -v sudo > /dev/null; then csudo="sudo " + csudouser="sudo -u ${USER} " fi initd_mod=0 @@ -63,6 +90,14 @@ elif $(which service &> /dev/null); then else service_mod=2 fi +if [ "$osType" = "Darwin" ]; then + if [ -d "${install_main_dir}" ];then + ${csudo}rm -rf ${install_main_dir} + fi + ${csudo}mkdir -p ${install_main_dir} + ${csudo}rm -rf ${install_main_dir} + ${csudo}cp -rf tdengine ${install_main_dir} +fi function kill_taosadapter() { # ${csudo}pkill -f taosadapter || : @@ -96,22 +131,24 @@ function install_lib() { ${csudo}rm -f ${lib_link_dir}/libtaos* || : ${csudo}rm -f ${lib64_link_dir}/libtaos* || : - [ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || : - [ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || : + [ -f ${lib_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.${lib_file_ext} || : + [ -f ${lib64_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.${lib_file_ext} || : ${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1 ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so - [ -f ${lib_dir}/libtaosws.so ] && ${csudo}ln -sf ${lib_dir}/libtaosws.so ${lib_link_dir}/libtaosws.so ||: + [ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib_link_dir}/libtaosws.${lib_file_ext} ||: if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then ${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : - [ -f ${lib_dir}/libtaosws.so ] && ${csudo}ln -sf ${lib_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || : + [ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib64_link_dir}/libtaosws.${lib_file_ext} || : fi - ${csudo}ldconfig + if [ "$osType" != "Darwin" ]; then + ${csudo}ldconfig + fi } function install_bin() { @@ -138,6 +175,7 @@ function install_bin() { [ -x ${bin_dir}/TDinsight.sh ] && ${csudo}ln -sf ${bin_dir}/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : [ -x ${bin_dir}/taosdump ] && ${csudo}ln -s ${bin_dir}/taosdump ${bin_link_dir}/taosdump || : [ -x ${bin_dir}/set_core.sh ] && ${csudo}ln -s ${bin_dir}/set_core.sh ${bin_link_dir}/set_core || : + [ -x ${bin_dir}/remove.sh ] && ${csudo}ln -s ${bin_dir}/remove.sh ${bin_link_dir}/rmtaos || : } function add_newHostname_to_hosts() { @@ -466,6 +504,14 @@ function install_service_on_systemd() { ${csudo}systemctl enable taosd } +function install_service_on_launchctl() { + if [ -f ${install_main_dir}/service/com.taosdata.taosd.plist ]; then + ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : + ${csudo}cp ${install_main_dir}/service/com.taosdata.taosd.plist /Library/LaunchDaemons/com.taosdata.taosd.plist || : + ${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosd.plist || : + fi +} + function install_taosadapter_service() { if ((${service_mod}==0)); then [ -f ${script_dir}/../cfg/taosadapter.service ] &&\ @@ -476,6 +522,7 @@ function install_taosadapter_service() { } function install_service() { + if [ "$osType" != "Darwin" ]; then if ((${service_mod}==0)); then install_service_on_systemd elif ((${service_mod}==1)); then @@ -485,6 +532,25 @@ function install_service() { kill_taosadapter kill_taosd fi + else + install_service_on_launchctl + fi +} + +function install_app() { + if [ "$osType" = "Darwin" ]; then + if [ -f ${install_main_dir}/service/TDengine ]; then + ${csudo}rm -rf /Applications/TDengine.app && + ${csudo}mkdir -p /Applications/TDengine.app/Contents/MacOS/ && + ${csudo}cp ${install_main_dir}/service/TDengine /Applications/TDengine.app/Contents/MacOS/ && + echo "" | ${csudo}tee /Applications/TDengine.app/Contents/Info.plist > /dev/null && + ${csudo}sips -i ${install_main_dir}/service/logo.png > /dev/null && + DeRez -only icns ${install_main_dir}/service/logo.png | ${csudo}tee /Applications/TDengine.app/mac_logo.rsrc > /dev/null && + ${csudo}rez -append /Applications/TDengine.app/mac_logo.rsrc -o $'/Applications/TDengine.app/Icon\r' && + ${csudo}SetFile -a C /Applications/TDengine.app/ && + ${csudo}rm /Applications/TDengine.app/mac_logo.rsrc + fi + fi } function install_TDengine() { @@ -492,7 +558,7 @@ function install_TDengine() { #install log and data dir , then ln to /usr/local/taos ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - ${csudo}mkdir -p ${data_dir} + ${csudo}mkdir -p ${data_dir} && ${csudo}chmod 777 ${data_dir} ${csudo}rm -rf ${log_link_dir} || : ${csudo}rm -rf ${data_link_dir} || : @@ -508,6 +574,7 @@ function install_TDengine() { install_taosadapter_config install_taosadapter_service install_service + install_app # Ask if to start the service #echo diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index a648750904c9102c1786f5d1de1655a54d1e0a9a..6172fc9bc8bcce6a311b82cff52b797c3731b296 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -6,12 +6,31 @@ set -e #set -x verMode=edge +osType=`uname` RED='\033[0;31m' GREEN='\033[1;32m' NC='\033[0m' -installDir="/usr/local/taos" +if [ "$osType" != "Darwin" ]; then + installDir="/usr/local/taos" + bin_link_dir="/usr/bin" + lib_link_dir="/usr/lib" + lib64_link_dir="/usr/lib64" + inc_link_dir="/usr/include" +else + if [ -d "/usr/local/Cellar/" ];then + installDir="/usr/local/Cellar/tdengine/${verNumber}" + elif [ -d "/opt/homebrew/Cellar/" ];then + installDir="/opt/homebrew/Cellar/tdengine/${verNumber}" + else + installDir="/usr/local/taos" + fi + bin_link_dir="/usr/local/bin" + lib_link_dir="/usr/local/lib" + lib64_link_dir="/usr/local/lib" + inc_link_dir="/usr/local/include" +fi serverName="taosd" clientName="taos" uninstallScript="rmtaos" @@ -22,11 +41,8 @@ install_main_dir=${installDir} data_link_dir=${installDir}/data log_link_dir=${installDir}/log cfg_link_dir=${installDir}/cfg -bin_link_dir="/usr/bin" local_bin_link_dir="/usr/local/bin" -lib_link_dir="/usr/lib" -lib64_link_dir="/usr/lib64" -inc_link_dir="/usr/include" + service_config_dir="/etc/systemd/system" taos_service_name=${serverName} @@ -82,6 +98,7 @@ function clean_bin() { # Remove link ${csudo}rm -f ${bin_link_dir}/${clientName} || : ${csudo}rm -f ${bin_link_dir}/${serverName} || : + ${csudo}rm -f ${bin_link_dir}/udfd || : ${csudo}rm -f ${bin_link_dir}/taosadapter || : ${csudo}rm -f ${bin_link_dir}/taosBenchmark || : ${csudo}rm -f ${bin_link_dir}/taosdemo || : @@ -103,7 +120,7 @@ function clean_lib() { [ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || : ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : - [ -f ${lib64_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.so || : + [ -f ${lib64_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || : #${csudo}rm -rf ${v15_java_app_dir} || : } @@ -195,12 +212,20 @@ function clean_service_on_sysvinit() { fi } +function clean_service_on_launchctl() { + ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : + ${csudo}rm /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : +} + function clean_service() { if ((${service_mod} == 0)); then clean_service_on_systemd elif ((${service_mod} == 1)); then clean_service_on_sysvinit else + if [ "$osType" = "Darwin" ]; then + clean_service_on_launchctl + fi kill_taosadapter kill_taosd kill_tarbitrator @@ -241,6 +266,9 @@ elif echo $osinfo | grep -qwi "centos"; then # echo "this is centos system" ${csudo}rpm -e --noscripts tdengine >/dev/null 2>&1 || : fi +if [ "$osType" = "Darwin" ]; then + ${csudo}rm -rf /Applications/TDengine.app +fi echo -e "${GREEN}${productName} is removed successfully!${NC}" echo diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index 1442ed2e0509e37d8b21806dc05343adcaa0f32c..63a28e17ed7461d8b0eb95c8eece7f31f0f43710 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -32,7 +32,7 @@ SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandF } sprintf(streamPath, "%s/%s", pMeta->path, "checkpoints"); - mkdir(streamPath, 0755); + taosMulModeMkDir(streamPath, 0755); taosMemoryFree(streamPath); if (tdbTbOpen("task.db", sizeof(int32_t), -1, NULL, pMeta->db, &pMeta->pTaskDb) < 0) { diff --git a/source/libs/tdb/src/db/tdbDb.c b/source/libs/tdb/src/db/tdbDb.c index cc8bdca75d4984cf47f0d455d5ad64bacdb5c872..42aeeae19a1afe6a1738e377d7fe441a40fda3d0 100644 --- a/source/libs/tdb/src/db/tdbDb.c +++ b/source/libs/tdb/src/db/tdbDb.c @@ -62,7 +62,7 @@ int32_t tdbOpen(const char *dbname, int32_t szPage, int32_t pages, TDB **ppDb) { } memset(pDb->pgrHash, 0, tsize); - mkdir(dbname, 0755); + taosMulModeMkDir(dbname, 0755); #ifdef USE_MAINDB // open main db diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index cf74525543c0743e8d44225de7b888fdbd1ae790..0cc946ac2182bd351f703a4acab295d1bb223c0f 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -121,6 +121,8 @@ int32_t taosMkDir(const char *dirname) { if (taosDirExist(dirname)) return 0; #ifdef WINDOWS int32_t code = _mkdir(dirname, 0755); +#elif defined(DARWIN) + int32_t code = mkdir(dirname, 0777); #else int32_t code = mkdir(dirname, 0755); #endif @@ -156,6 +158,8 @@ int32_t taosMulMkDir(const char *dirname) { *pos = '\0'; #ifdef WINDOWS code = _mkdir(temp, 0755); +#elif defined(DARWIN) + code = mkdir(dirname, 0777); #else code = mkdir(temp, 0755); #endif @@ -170,6 +174,8 @@ int32_t taosMulMkDir(const char *dirname) { if (*(pos - 1) != TD_DIRSEP[0]) { #ifdef WINDOWS code = _mkdir(temp, 0755); +#elif defined(DARWIN) + code = mkdir(dirname, 0777); #else code = mkdir(temp, 0755); #endif @@ -179,7 +185,6 @@ int32_t taosMulMkDir(const char *dirname) { } } - // int32_t code = mkdir(dirname, 0755); if (code < 0 && errno == EEXIST) { return 0; } @@ -215,6 +220,8 @@ int32_t taosMulModeMkDir(const char *dirname, int mode) { *pos = '\0'; #ifdef WINDOWS code = _mkdir(temp, mode); +#elif defined(DARWIN) + code = mkdir(dirname, 0777); #else code = mkdir(temp, mode); #endif @@ -229,6 +236,8 @@ int32_t taosMulModeMkDir(const char *dirname, int mode) { if (*(pos - 1) != TD_DIRSEP[0]) { #ifdef WINDOWS code = _mkdir(temp, mode); +#elif defined(DARWIN) + code = mkdir(dirname, 0777); #else code = mkdir(temp, mode); #endif diff --git a/source/os/src/osEnv.c b/source/os/src/osEnv.c index 8f6800c7bed8d1d987ae10aec8a67023792bf9dc..9511230f8d7ee98e8353b9758d246e963bdc6960 100644 --- a/source/os/src/osEnv.c +++ b/source/os/src/osEnv.c @@ -59,34 +59,18 @@ void osDefaultInit() { if (tmpDir != NULL) { strcpy(tsTempDir, tmpDir); } - - if (configDir[0] == 0) { - strcpy(configDir, "C:\\TDengine\\cfg"); - } - strcpy(tsDataDir, "C:\\TDengine\\data"); - strcpy(tsLogDir, "C:\\TDengine\\log"); - strcpy(tsTempDir, "C:\\Windows\\Temp"); strcpy(tsOsName, "Windows"); - #elif defined(_TD_DARWIN_64) - if (configDir[0] == 0) { - strcpy(configDir, "/usr/local/etc/taos"); - } - strcpy(tsDataDir, "/usr/local/var/lib/taos"); - strcpy(tsLogDir, "/usr/local/var/log/taos"); - strcpy(tsTempDir, "/tmp/taosd"); strcpy(tsOsName, "Darwin"); - #else - if (configDir[0] == 0) { - strcpy(configDir, "/etc/taos"); - } - strcpy(tsDataDir, "/var/lib/taos"); - strcpy(tsLogDir, "/var/log/taos"); - strcpy(tsTempDir, "/tmp"); strcpy(tsOsName, "Linux"); - #endif + if (configDir[0] == 0) { + strcpy(configDir, TD_CFG_DIR_PATH); + } + strcpy(tsDataDir, TD_DATA_DIR_PATH); + strcpy(tsLogDir, TD_LOG_DIR_PATH); + strcpy(tsTempDir, TD_TMP_DIR_PATH); } void osUpdate() { diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 03097e31b9d65c48cdc543524d12dc0a80e2c6b3..98d21a4f2cc327e429646b2e045ae44d468c9523 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -1,6 +1,11 @@ IF (TD_WEBSOCKET) + IF (TD_LINUX) + SET(websocket_lib_file "libtaosws.so") + ELSEIF (TD_DARWIN) + SET(websocket_lib_file "libtaosws.dylib") + ENDIF () MESSAGE("${Green} use libtaos-ws${ColourReset}") - IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/libtaosws.so" OR "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/libtaosws.so" IS_NEWER_THAN "${CMAKE_SOURCE_DIR}/.git/modules/tools/taosws-rs/FETCH_HEAD") + IF (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/${websocket_lib_file}" OR "${CMAKE_CURRENT_SOURCE_DIR}/taosws-rs/target/release/${websocket_lib_file}" IS_NEWER_THAN "${CMAKE_SOURCE_DIR}/.git/modules/tools/taosws-rs/FETCH_HEAD") include(ExternalProject) ExternalProject_Add(taosws-rs PREFIX "taosws-rs" @@ -15,7 +20,7 @@ IF (TD_WEBSOCKET) COMMAND cargo build --release -p taos-ws-sys COMMAND ./taos-ws-sys/ci/package.sh INSTALL_COMMAND - COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib + COMMAND cmake -E copy target/libtaosws/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include ) @@ -34,7 +39,7 @@ IF (TD_WEBSOCKET) COMMAND cargo build --release -p taos-ws-sys COMMAND ./taos-ws-sys/ci/package.sh INSTALL_COMMAND - COMMAND cmake -E copy target/libtaosws/libtaosws.so ${CMAKE_BINARY_DIR}/build/lib + COMMAND cmake -E copy target/libtaosws/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include COMMAND cmake -E copy target/libtaosws/taosws.h ${CMAKE_BINARY_DIR}/build/include ) diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 488b623f89162b4948ea913100737ac96bf0f148..45a6f8c16f60dc2d4cc57f4e57a9e44034ec3aaa 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -6,6 +6,10 @@ IF (TD_LINUX AND TD_WEBSOCKET) ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include -ltaosws) SET(LINK_WEBSOCKET "-L${CMAKE_BINARY_DIR}/build/lib -ltaosws") ADD_DEPENDENCIES(shell taosws-rs) +ELSEIF (TD_DARWIN AND TD_WEBSOCKET) + ADD_DEFINITIONS(-DWEBSOCKET -I${CMAKE_BINARY_DIR}/build/include) + SET(LINK_WEBSOCKET "${CMAKE_BINARY_DIR}/build/lib/libtaosws.dylib") + ADD_DEPENDENCIES(shell taosws-rs) ELSE () SET(LINK_WEBSOCKET "") ENDIF ()