Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
冷面1992
TDengine
提交
7d815b24
TDengine
项目概览
冷面1992
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7d815b24
编写于
1月 16, 2020
作者:
P
plum-lihui
提交者:
GitHub
1月 16, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1145 from taosdata/feature/slguan
Mac client
上级
e124c8ee
36eef3ae
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
1338 addition
and
274 deletion
+1338
-274
CMakeLists.txt
CMakeLists.txt
+5
-0
packaging/deb/makedeb.sh
packaging/deb/makedeb.sh
+1
-1
packaging/release.sh
packaging/release.sh
+61
-29
packaging/rpm/makerpm.sh
packaging/rpm/makerpm.sh
+2
-2
packaging/rpm/taosd
packaging/rpm/taosd
+1
-1
packaging/tools/install.sh
packaging/tools/install.sh
+174
-5
packaging/tools/install_client.sh
packaging/tools/install_client.sh
+69
-37
packaging/tools/make_install.sh
packaging/tools/make_install.sh
+189
-102
packaging/tools/makeclient.sh
packaging/tools/makeclient.sh
+52
-9
packaging/tools/makepkg.sh
packaging/tools/makepkg.sh
+28
-5
packaging/tools/remove.sh
packaging/tools/remove.sh
+26
-1
packaging/tools/remove_client.sh
packaging/tools/remove_client.sh
+5
-0
src/client/CMakeLists.txt
src/client/CMakeLists.txt
+17
-15
src/client/src/tscServer.c
src/client/src/tscServer.c
+6
-6
src/kit/shell/CMakeLists.txt
src/kit/shell/CMakeLists.txt
+4
-1
src/kit/shell/src/shellDarwin.c
src/kit/shell/src/shellDarwin.c
+532
-0
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+1
-1
src/kit/shell/src/shellImport.c
src/kit/shell/src/shellImport.c
+4
-12
src/os/darwin/inc/os.h
src/os/darwin/inc/os.h
+68
-32
src/os/darwin/src/tdarwin.c
src/os/darwin/src/tdarwin.c
+45
-6
src/rpc/src/tudp.c
src/rpc/src/tudp.c
+5
-0
src/util/CMakeLists.txt
src/util/CMakeLists.txt
+30
-3
src/util/src/tnote.c
src/util/src/tnote.c
+7
-2
src/util/src/version.c
src/util/src/version.c
+5
-3
tests/examples/c/CMakeLists.txt
tests/examples/c/CMakeLists.txt
+1
-1
未找到文件。
CMakeLists.txt
浏览文件 @
7d815b24
...
...
@@ -280,6 +280,11 @@ IF (NOT DEFINED TD_CLUSTER)
INSTALL
(
FILES
${
LIBRARY_OUTPUT_PATH
}
/libtaos.dll DESTINATION driver
)
INSTALL
(
FILES
${
LIBRARY_OUTPUT_PATH
}
/libtaos.dll.a DESTINATION driver
)
ENDIF
()
ELSEIF
(
TD_DARWIN_64
)
SET
(
TD_MAKE_INSTALL_SH
"
${
TD_COMMUNITY_DIR
}
/packaging/tools/make_install.sh"
)
INSTALL
(
CODE
"MESSAGE(
\"
make install script:
${
TD_MAKE_INSTALL_SH
}
\"
)"
)
INSTALL
(
CODE
"execute_process(COMMAND chmod 777
${
TD_MAKE_INSTALL_SH
}
)"
)
INSTALL
(
CODE
"execute_process(COMMAND
${
TD_MAKE_INSTALL_SH
}
${
TD_COMMUNITY_DIR
}
${
PROJECT_BINARY_DIR
}
Darwin)"
)
ENDIF
()
ENDIF
()
...
...
packaging/deb/makedeb.sh
浏览文件 @
7d815b24
...
...
@@ -2,7 +2,7 @@
#
# Generate deb package for ubuntu
set
-e
#set -x
#
set -x
#curr_dir=$(pwd)
compile_dir
=
$1
...
...
packaging/release.sh
浏览文件 @
7d815b24
...
...
@@ -3,7 +3,7 @@
# Generate the deb package for ubunt, or rpm package for centos, or tar.gz package for other linux os
set
-e
#
set -x
#set -x
# releash.sh -v [cluster | lite] -c [aarch32 | aarch64 | x64 | x86 | mips64 ...] -o [Linux | Kylin | Alpine | Raspberrypi | Darwin | Windows | ...] -V [stable | beta]
...
...
@@ -46,8 +46,17 @@ done
echo
"verMode=
${
verMode
}
verType=
${
verType
}
cpuType=
${
cpuType
}
osType=
${
osType
}
"
curr_dir
=
$(
pwd
)
script_dir
=
"
$(
dirname
$(
readlink
-f
$0
))
"
top_dir
=
"
$(
readlink
-f
${
script_dir
}
/..
)
"
if
[
"
$osType
"
!=
"Darwin"
]
;
then
script_dir
=
"
$(
dirname
$(
readlink
-f
$0
))
"
top_dir
=
"
$(
readlink
-f
${
script_dir
}
/..
)
"
else
script_dir
=
`
dirname
$0
`
cd
${
script_dir
}
script_dir
=
"
$(
pwd
)
"
top_dir
=
${
script_dir
}
/..
fi
versioninfo
=
"
${
top_dir
}
/src/util/src/version.c"
csudo
=
""
...
...
@@ -147,7 +156,14 @@ build_time=$(date +"%F %R")
echo
"char version[64] =
\"
${
version
}
\"
;"
>
${
versioninfo
}
echo
"char compatible_version[64] =
\"
${
compatible_version
}
\"
;"
>>
${
versioninfo
}
echo
"char gitinfo[128] =
\"
$(
git rev-parse
--verify
HEAD
)
\"
;"
>>
${
versioninfo
}
echo
"char gitinfoOfInternal[128] =
\"\"
;"
>>
${
versioninfo
}
if
[
"
$verMode
"
!=
"cluster"
]
;
then
echo
"char gitinfoOfInternal[128] =
\"\"
;"
>>
${
versioninfo
}
else
enterprise_dir
=
"
${
top_dir
}
/../enterprise"
cd
${
enterprise_dir
}
echo
"char gitinfoOfInternal[128] =
\"
$(
git rev-parse
--verify
HEAD
)
\"
;"
>>
${
versioninfo
}
cd
${
curr_dir
}
fi
echo
"char buildinfo[512] =
\"
Built by
${
USER
}
at
${
build_time
}
\"
;"
>>
${
versioninfo
}
echo
""
>>
${
versioninfo
}
tmp_version
=
$(
echo
$version
|
tr
-s
"."
"_"
)
...
...
@@ -167,15 +183,23 @@ if [ -d ${compile_dir} ]; then
${
csudo
}
rm
-rf
${
compile_dir
}
fi
${
csudo
}
mkdir
-p
${
compile_dir
}
if
[
"
$osType
"
!=
"Darwin"
]
;
then
${
csudo
}
mkdir
-p
${
compile_dir
}
else
mkdir
-p
${
compile_dir
}
fi
cd
${
compile_dir
}
# check support cpu type
if
[[
"
$cpuType
"
==
"x64"
]]
||
[[
"
$cpuType
"
==
"aarch64"
]]
||
[[
"
$cpuType
"
==
"aarch32"
]]
||
[[
"
$cpuType
"
==
"mips64"
]]
;
then
cmake ../
-DCPUTYPE
=
${
cpuType
}
if
[
"
$verMode
"
!=
"cluster"
]
;
then
cmake ../
-DCPUTYPE
=
${
cpuType
}
else
cmake ../../
-DCPUTYPE
=
${
cpuType
}
fi
else
echo
"input cpuType=
${
cpuType
}
error!!!"
exit
1
echo
"input cpuType=
${
cpuType
}
error!!!"
exit
1
fi
make
...
...
@@ -187,28 +211,36 @@ cd ${curr_dir}
#osinfo=$(cat /etc/os-release | grep "NAME" | cut -d '"' -f2)
#echo "osinfo: ${osinfo}"
echo
"====do deb package for the ubuntu system===="
output_dir
=
"
${
top_dir
}
/debs"
if
[
-d
${
output_dir
}
]
;
then
${
csudo
}
rm
-rf
${
output_dir
}
fi
${
csudo
}
mkdir
-p
${
output_dir
}
cd
${
script_dir
}
/deb
${
csudo
}
./makedeb.sh
${
compile_dir
}
${
output_dir
}
${
version
}
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
echo
"====do rpm package for the centos system===="
output_dir
=
"
${
top_dir
}
/rpms"
if
[
-d
${
output_dir
}
]
;
then
${
csudo
}
rm
-rf
${
output_dir
}
if
[
"
$osType
"
!=
"Darwin"
]
;
then
if
[
"
$verMode
"
!=
"cluster"
]
;
then
echo
"====do deb package for the ubuntu system===="
output_dir
=
"
${
top_dir
}
/debs"
if
[
-d
${
output_dir
}
]
;
then
${
csudo
}
rm
-rf
${
output_dir
}
fi
${
csudo
}
mkdir
-p
${
output_dir
}
cd
${
script_dir
}
/deb
${
csudo
}
./makedeb.sh
${
compile_dir
}
${
output_dir
}
${
version
}
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
echo
"====do rpm package for the centos system===="
output_dir
=
"
${
top_dir
}
/rpms"
if
[
-d
${
output_dir
}
]
;
then
${
csudo
}
rm
-rf
${
output_dir
}
fi
${
csudo
}
mkdir
-p
${
output_dir
}
cd
${
script_dir
}
/rpm
${
csudo
}
./makerpm.sh
${
compile_dir
}
${
output_dir
}
${
version
}
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
fi
echo
"====do tar.gz package for all systems===="
cd
${
script_dir
}
/tools
${
csudo
}
./makepkg.sh
${
compile_dir
}
${
version
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
${
csudo
}
./makeclient.sh
${
compile_dir
}
${
version
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
else
cd
${
script_dir
}
/tools
./makeclient.sh
${
compile_dir
}
${
version
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
fi
${
csudo
}
mkdir
-p
${
output_dir
}
cd
${
script_dir
}
/rpm
${
csudo
}
./makerpm.sh
${
compile_dir
}
${
output_dir
}
${
version
}
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
echo
"====do tar.gz package for all systems===="
cd
${
script_dir
}
/tools
${
csudo
}
./makepkg.sh
${
compile_dir
}
${
version
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
${
csudo
}
./makeclient.sh
${
compile_dir
}
${
version
}
"
${
build_time
}
"
${
cpuType
}
${
osType
}
${
verMode
}
${
verType
}
# 4. Clean up temporary compile directories
#${csudo} rm -rf ${compile_dir}
...
...
packaging/rpm/makerpm.sh
浏览文件 @
7d815b24
...
...
@@ -2,8 +2,8 @@
#
# Generate rpm package for centos
#
set -e
#set -x
set
-e
#
set -x
#curr_dir=$(pwd)
compile_dir
=
$1
...
...
packaging/rpm/taosd
浏览文件 @
7d815b24
...
...
@@ -26,7 +26,7 @@ MAX_OPEN_FILES=65535
# Default program options
NAME
=
taosd
PROG
=
/usr/local/
bin/taos
/taosd
PROG
=
/usr/local/
taos/bin
/taosd
USER
=
root
GROUP
=
root
...
...
packaging/tools/install.sh
100755 → 100644
浏览文件 @
7d815b24
...
...
@@ -6,6 +6,8 @@
set
-e
#set -x
verMode
=
lite
# -----------------------Variables definition---------------------
script_dir
=
$(
dirname
$(
readlink
-f
"
$0
"
))
# Dynamic directory
...
...
@@ -27,7 +29,12 @@ install_main_dir="/usr/local/taos"
# old bin dir
bin_dir
=
"/usr/local/taos/bin"
# v1.5 jar dir
v15_java_app_dir
=
"/usr/local/lib/taos"
service_config_dir
=
"/etc/systemd/system"
nginx_port
=
6060
nginx_dir
=
"/usr/local/nginxd"
# Color setting
RED
=
'\033[0;31m'
...
...
@@ -41,6 +48,8 @@ if command -v sudo > /dev/null; then
csudo
=
"sudo"
fi
update_flag
=
0
initd_mod
=
0
service_mod
=
2
if
pidof systemd &> /dev/null
;
then
...
...
@@ -106,6 +115,9 @@ function install_main_path() {
${
csudo
}
mkdir
-p
${
install_main_dir
}
/examples
${
csudo
}
mkdir
-p
${
install_main_dir
}
/include
${
csudo
}
mkdir
-p
${
install_main_dir
}
/init.d
if
[
"
$verMode
"
==
"cluster"
]
;
then
${
csudo
}
mkdir
-p
${
nginx_dir
}
fi
}
function
install_bin
()
{
...
...
@@ -124,16 +136,30 @@ function install_bin() {
[
-x
${
install_main_dir
}
/bin/taosdump
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taosdump
${
bin_link_dir
}
/taosdump
||
:
[
-x
${
install_main_dir
}
/bin/taosdemo
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taosdemo
${
bin_link_dir
}
/taosdemo
||
:
[
-x
${
install_main_dir
}
/bin/remove.sh
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/remove.sh
${
bin_link_dir
}
/rmtaos
||
:
if
[
"
$verMode
"
==
"cluster"
]
;
then
${
csudo
}
cp
-r
${
script_dir
}
/nginxd/
*
${
nginx_dir
}
&&
${
csudo
}
chmod
0555
${
nginx_dir
}
/
*
${
csudo
}
mkdir
-p
${
nginx_dir
}
/logs
${
csudo
}
chmod
777
${
nginx_dir
}
/sbin/nginx
fi
}
function
install_lib
()
{
# Remove links
${
csudo
}
rm
-f
${
lib_link_dir
}
/libtaos.
*
||
:
${
csudo
}
rm
-rf
${
v15_java_app_dir
}
||
:
${
csudo
}
cp
-rf
${
script_dir
}
/driver/
*
${
install_main_dir
}
/driver
&&
${
csudo
}
chmod
777
${
install_main_dir
}
/driver/
*
${
csudo
}
ln
-s
${
install_main_dir
}
/driver/libtaos.
*
${
lib_link_dir
}
/libtaos.so.1
${
csudo
}
ln
-s
${
lib_link_dir
}
/libtaos.so.1
${
lib_link_dir
}
/libtaos.so
if
[
"
$verMode
"
==
"cluster"
]
;
then
# Compatible with version 1.5
${
csudo
}
mkdir
-p
${
v15_java_app_dir
}
${
csudo
}
ln
-s
${
install_main_dir
}
/connector/taos-jdbcdriver-1.0.2-dist.jar
${
v15_java_app_dir
}
/JDBCDriver-1.0.2-dist.jar
${
csudo
}
chmod
777
${
v15_java_app_dir
}
||
:
fi
}
function
install_header
()
{
...
...
@@ -154,6 +180,57 @@ function install_config() {
${
csudo
}
cp
-f
${
script_dir
}
/cfg/taos.cfg
${
install_main_dir
}
/cfg/taos.cfg.org
${
csudo
}
ln
-s
${
cfg_install_dir
}
/taos.cfg
${
install_main_dir
}
/cfg
if
[
"
$verMode
"
==
"cluster"
]
;
then
[
!
-z
$1
]
&&
return
0
||
:
# only install client
if
((
${
update_flag
}
==
1
))
;
then
return
0
fi
IP_FORMAT
=
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
IP_PATTERN
=
"
\b
$IP_FORMAT
\.
$IP_FORMAT
\.
$IP_FORMAT
\.
$IP_FORMAT
\b
"
echo
echo
-e
-n
"
${
GREEN
}
Enter the IP address of an existing TDengine cluster node to join
${
NC
}
OR
${
GREEN
}
leave it blank to build one
${
NC
}
:"
read
masterIp
while
true
;
do
if
[
!
-z
"
$masterIp
"
]
;
then
# check the format of the masterIp
if
[[
$masterIp
=
~
$IP_PATTERN
]]
;
then
# Write the first IP to configuration file
sudo sed
-i
-r
"s/#*
\s
*(masterIp
\s
*).*/
\1
$masterIp
/"
${
cfg_dir
}
/taos.cfg
# Get the second IP address
echo
echo
-e
-n
"
${
GREEN
}
Enter the IP address of another node in cluster
${
NC
}
OR
${
GREEN
}
leave it blank to skip
${
NC
}
: "
read
secondIp
while
true
;
do
if
[
!
-z
"
$secondIp
"
]
;
then
if
[[
$secondIp
=
~
$IP_PATTERN
]]
;
then
# Write the second IP to configuration file
sudo sed
-i
-r
"s/#*
\s
*(secondIp
\s
*).*/
\1
$secondIp
/"
${
cfg_dir
}
/taos.cfg
break
else
read
-p
"Please enter the correct IP address: "
secondIp
fi
else
break
fi
done
break
else
read
-p
"Please enter the correct IP address: "
masterIp
fi
else
break
fi
done
fi
}
...
...
@@ -175,7 +252,9 @@ function install_connector() {
}
function
install_examples
()
{
${
csudo
}
cp
-rf
${
script_dir
}
/examples/
*
${
install_main_dir
}
/examples
if
[
-d
${
script_dir
}
/examples
]
;
then
${
csudo
}
cp
-rf
${
script_dir
}
/examples/
*
${
install_main_dir
}
/examples
fi
}
function
clean_service_on_sysvinit
()
{
...
...
@@ -240,7 +319,19 @@ function clean_service_on_systemd() {
${
csudo
}
systemctl disable taosd &> /dev/null
||
echo
&> /dev/null
${
csudo
}
rm
-f
${
taosd_service_config
}
}
if
[
"
$verMode
"
==
"cluster"
]
;
then
nginx_service_config
=
"
${
service_config_dir
}
/nginxd.service"
if
systemctl is-active
--quiet
nginxd
;
then
echo
"Nginx for TDengine is running, stopping it..."
${
csudo
}
systemctl stop nginxd &> /dev/null
||
echo
&> /dev/null
fi
${
csudo
}
systemctl disable nginxd &> /dev/null
||
echo
&> /dev/null
${
csudo
}
rm
-f
${
nginx_service_config
}
fi
}
# taos:2345:respawn:/etc/init.d/taosd start
...
...
@@ -269,6 +360,36 @@ function install_service_on_systemd() {
${
csudo
}
bash
-c
"echo '[Install]' >>
${
taosd_service_config
}
"
${
csudo
}
bash
-c
"echo 'WantedBy=multi-user.target' >>
${
taosd_service_config
}
"
${
csudo
}
systemctl
enable
taosd
if
[
"
$verMode
"
==
"cluster"
]
;
then
nginx_service_config
=
"
${
service_config_dir
}
/nginxd.service"
${
csudo
}
bash
-c
"echo '[Unit]' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'Description=Nginx For TDengine Service' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'After=network-online.target' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'Wants=network-online.target' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo '[Service]' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'Type=forking' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'PIDFile=/usr/local/nginxd/logs/nginx.pid' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'ExecStart=/usr/local/nginxd/sbin/nginx' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'ExecStop=/usr/local/nginxd/sbin/nginx -s stop' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'LimitNOFILE=infinity' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'LimitNPROC=infinity' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'LimitCORE=infinity' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'TimeoutStartSec=0' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'StandardOutput=null' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'Restart=always' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'StartLimitBurst=3' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'StartLimitInterval=60s' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo '[Install]' >>
${
nginx_service_config
}
"
${
csudo
}
bash
-c
"echo 'WantedBy=multi-user.target' >>
${
nginx_service_config
}
"
if
!
${
csudo
}
systemctl
enable
nginxd &> /dev/null
;
then
${
csudo
}
systemctl daemon-reexec
${
csudo
}
systemctl
enable
nginxd
fi
${
csudo
}
systemctl start nginxd
fi
}
function
install_service
()
{
...
...
@@ -363,6 +484,21 @@ function update_TDengine() {
install_bin
install_service
install_config
if
[
"
$verMode
"
==
"cluster"
]
;
then
# Check if openresty is installed
openresty_work
=
false
# Check if nginx is installed successfully
if
type
curl &> /dev/null
;
then
if
curl
-sSf
http://127.0.0.1:
${
nginx_port
}
&> /dev/null
;
then
echo
-e
"
\0
33[44;32;1mNginx for TDengine is updated successfully!
${
NC
}
"
openresty_work
=
true
else
echo
-e
"
\0
33[44;31;5mNginx for TDengine does not work! Please try again!
\0
33[0m"
fi
fi
fi
echo
echo
-e
"
\0
33[44;32;1mTDengine is updated successfully!
${
NC
}
"
...
...
@@ -376,7 +512,15 @@ function update_TDengine() {
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
: ./taosd
${
NC
}
"
fi
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
if
[
"
$verMode
"
==
"cluster"
]
;
then
if
[
${
openresty_work
}
=
'true'
]
;
then
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell OR from
${
GREEN_UNDERLINE
}
http://127.0.0.1:
${
nginx_port
}${
NC
}
"
else
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
fi
else
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
fi
echo
echo
-e
"
\0
33[44;32;1mTDengine is updated successfully!
${
NC
}
"
else
...
...
@@ -416,6 +560,20 @@ function install_TDengine() {
# For installing new
install_bin
install_service
if
[
"
$verMode
"
==
"cluster"
]
;
then
openresty_work
=
false
# Check if nginx is installed successfully
if
type
curl &> /dev/null
;
then
if
curl
-sSf
http://127.0.0.1:
${
nginx_port
}
&> /dev/null
;
then
echo
-e
"
\0
33[44;32;1mNginx for TDengine is installed successfully!
${
NC
}
"
openresty_work
=
true
else
echo
-e
"
\0
33[44;31;5mNginx for TDengine does not work! Please try again!
\0
33[0m"
fi
fi
fi
install_config
# Ask if to start the service
...
...
@@ -430,8 +588,17 @@ function install_TDengine() {
else
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
: taosd
${
NC
}
"
fi
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
if
[
"
$verMode
"
==
"cluster"
]
;
then
if
[
${
openresty_work
}
=
'true'
]
;
then
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell OR from
${
GREEN_UNDERLINE
}
http://127.0.0.1:
${
nginx_port
}${
NC
}
"
else
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
fi
else
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
fi
echo
echo
-e
"
\0
33[44;32;1mTDengine is installed successfully!
${
NC
}
"
else
# Only install client
...
...
@@ -450,6 +617,7 @@ function install_TDengine() {
if
[
-z
$1
]
;
then
# Install server and client
if
[
-x
${
bin_dir
}
/taosd
]
;
then
update_flag
=
1
update_TDengine
else
install_TDengine
...
...
@@ -457,6 +625,7 @@ if [ -z $1 ]; then
else
# Only install client
if
[
-x
${
bin_dir
}
/taos
]
;
then
update_flag
=
1
update_TDengine client
else
install_TDengine client
...
...
packaging/tools/install_client.sh
浏览文件 @
7d815b24
...
...
@@ -7,18 +7,35 @@ set -e
#set -x
# -----------------------Variables definition---------------------
script_dir
=
$(
dirname
$(
readlink
-f
"
$0
"
))
# Dynamic directory
data_dir
=
"/var/lib/taos"
log_dir
=
"/var/log/taos"
osType
=
Linux
if
[
"
$osType
"
!=
"Darwin"
]
;
then
script_dir
=
$(
dirname
$(
readlink
-f
"
$0
"
))
# Dynamic directory
data_dir
=
"/var/lib/taos"
log_dir
=
"/var/log/taos"
else
script_dir
=
`
dirname
$0
`
cd
${
script_dir
}
script_dir
=
"
$(
pwd
)
"
data_dir
=
"/var/lib/taos"
log_dir
=
"~/TDengineLog"
fi
log_link_dir
=
"/usr/local/taos/log"
cfg_install_dir
=
"/etc/taos"
bin_link_dir
=
"/usr/bin"
lib_link_dir
=
"/usr/lib"
inc_link_dir
=
"/usr/include"
if
[
"
$osType
"
!=
"Darwin"
]
;
then
bin_link_dir
=
"/usr/bin"
lib_link_dir
=
"/usr/lib"
inc_link_dir
=
"/usr/include"
else
bin_link_dir
=
"/usr/local/bin"
lib_link_dir
=
"/usr/local/lib"
inc_link_dir
=
"/usr/local/include"
fi
#install main path
install_main_dir
=
"/usr/local/taos"
...
...
@@ -26,6 +43,8 @@ install_main_dir="/usr/local/taos"
# old bin dir
bin_dir
=
"/usr/local/taos/bin"
# v1.5 jar dir
v15_java_app_dir
=
"/usr/local/lib/taos"
# Color setting
RED
=
'\033[0;31m'
...
...
@@ -51,9 +70,9 @@ function kill_client() {
function
install_main_path
()
{
#create install main dir and all sub dir
${
csudo
}
rm
-rf
${
install_main_dir
}
||
:
${
csudo
}
mkdir
-p
${
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
}
/bin
${
csudo
}
mkdir
-p
${
install_main_dir
}
/connector
${
csudo
}
mkdir
-p
${
install_main_dir
}
/driver
${
csudo
}
mkdir
-p
${
install_main_dir
}
/examples
...
...
@@ -61,51 +80,60 @@ function install_main_path() {
}
function
install_bin
()
{
# Remove links
${
csudo
}
rm
-f
${
bin_link_dir
}
/taos
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosdump
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/rmtaos
||
:
# Remove links
${
csudo
}
rm
-f
${
bin_link_dir
}
/taos
||
:
if
[
"
$osType
"
==
"Darwin"
]
;
then
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosdump
||
:
fi
${
csudo
}
rm
-f
${
bin_link_dir
}
/rmtaos
||
:
${
csudo
}
cp
-r
${
script_dir
}
/bin/
*
${
install_main_dir
}
/bin
&&
${
csudo
}
chmod
0555
${
install_main_dir
}
/bin/
*
${
csudo
}
cp
-r
${
script_dir
}
/bin/
*
${
install_main_dir
}
/bin
&&
${
csudo
}
chmod
0555
${
install_main_dir
}
/bin/
*
#Make link
[
-x
${
install_main_dir
}
/bin/taos
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taos
${
bin_link_dir
}
/taos
||
:
[
-x
${
install_main_dir
}
/bin/taosdump
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taosdump
${
bin_link_dir
}
/taosdump
||
:
[
-x
${
install_main_dir
}
/bin/remove_client.sh
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/remove_client.sh
${
bin_link_dir
}
/rmtaos
||
:
[
-x
${
install_main_dir
}
/bin/taos
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taos
${
bin_link_dir
}
/taos
||
:
if
[
"
$osType
"
==
"Darwin"
]
;
then
[
-x
${
install_main_dir
}
/bin/taosdump
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taosdump
${
bin_link_dir
}
/taosdump
||
:
fi
[
-x
${
install_main_dir
}
/bin/remove_client.sh
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/remove_client.sh
${
bin_link_dir
}
/rmtaos
||
:
}
function
clean_lib
()
{
sudo rm
-f
/usr/lib/libtaos.
so
||
:
sudo rm
-f
/usr/lib/libtaos.
*
||
:
sudo rm
-rf
${
lib_dir
}
||
:
}
function
install_lib
()
{
# Remove links
${
csudo
}
rm
-f
${
lib_link_dir
}
/libtaos.
*
||
:
${
csudo
}
rm
-rf
${
v15_java_app_dir
}
||
:
${
csudo
}
cp
-rf
${
script_dir
}
/driver/
*
${
install_main_dir
}
/driver
&&
${
csudo
}
chmod
777
${
install_main_dir
}
/driver/
*
${
csudo
}
cp
-rf
${
script_dir
}
/driver/
*
${
install_main_dir
}
/driver
&&
${
csudo
}
chmod
777
${
install_main_dir
}
/driver/
*
${
csudo
}
ln
-s
${
install_main_dir
}
/driver/libtaos.
*
${
lib_link_dir
}
/libtaos.so.1
${
csudo
}
ln
-s
${
lib_link_dir
}
/libtaos.so.1
${
lib_link_dir
}
/libtaos.so
if
[
"
$osType
"
!=
"Darwin"
]
;
then
${
csudo
}
ln
-s
${
install_main_dir
}
/driver/libtaos.
*
${
lib_link_dir
}
/libtaos.so.1
${
csudo
}
ln
-s
${
lib_link_dir
}
/libtaos.so.1
${
lib_link_dir
}
/libtaos.so
else
${
csudo
}
ln
-s
${
install_main_dir
}
/driver/libtaos.
*
${
lib_link_dir
}
/libtaos.1.dylib
${
csudo
}
ln
-s
${
lib_link_dir
}
/libtaos.1.dylib
${
lib_link_dir
}
/libtaos.dylib
fi
}
function
install_header
()
{
${
csudo
}
rm
-f
${
inc_link_dir
}
/taos.h
${
inc_link_dir
}
/taoserror.h
||
:
${
csudo
}
cp
-f
${
script_dir
}
/inc/
*
${
install_main_dir
}
/include
&&
${
csudo
}
chmod
644
${
install_main_dir
}
/include/
*
${
csudo
}
cp
-f
${
script_dir
}
/inc/
*
${
install_main_dir
}
/include
&&
${
csudo
}
chmod
644
${
install_main_dir
}
/include/
*
${
csudo
}
ln
-s
${
install_main_dir
}
/include/taos.h
${
inc_link_dir
}
/taos.h
${
csudo
}
ln
-s
${
install_main_dir
}
/include/taoserror.h
${
inc_link_dir
}
/taoserror.h
}
function
install_config
()
{
#${csudo} rm -f ${install_main_dir}/cfg/taos.cfg || :
if
[
!
-f
${
cfg_install_dir
}
/taos.cfg
]
;
then
${
csudo
}
mkdir
-p
${
cfg_install_dir
}
[
-f
${
script_dir
}
/cfg/taos.cfg
]
&&
${
csudo
}
cp
${
script_dir
}
/cfg/taos.cfg
${
cfg_install_dir
}
${
csudo
}
chmod
644
${
cfg_install_dir
}
/
*
fi
fi
${
csudo
}
cp
-f
${
script_dir
}
/cfg/taos.cfg
${
install_main_dir
}
/cfg/taos.cfg.org
${
csudo
}
ln
-s
${
cfg_install_dir
}
/taos.cfg
${
install_main_dir
}
/cfg
}
...
...
@@ -113,8 +141,12 @@ function install_config() {
function
install_log
()
{
${
csudo
}
rm
-rf
${
log_dir
}
||
:
${
csudo
}
mkdir
-p
${
log_dir
}
&&
${
csudo
}
chmod
777
${
log_dir
}
if
[
"
$osType
"
!=
"Darwin"
]
;
then
${
csudo
}
mkdir
-p
${
log_dir
}
&&
${
csudo
}
chmod
777
${
log_dir
}
else
mkdir
-p
${
log_dir
}
&&
${
csudo
}
chmod
777
${
log_dir
}
fi
${
csudo
}
ln
-s
${
log_dir
}
${
install_main_dir
}
/log
}
...
...
@@ -142,7 +174,7 @@ function update_TDengine() {
kill_client
sleep
1
fi
install_main_path
install_log
...
...
@@ -152,7 +184,7 @@ function update_TDengine() {
install_examples
install_bin
install_config
echo
echo
-e
"
\0
33[44;32;1mTDengine client is updated successfully!
${
NC
}
"
...
...
@@ -168,16 +200,16 @@ function install_TDengine() {
tar
-zxf
taos.tar.gz
echo
-e
"
${
GREEN
}
Start to install TDengine client...
${
NC
}
"
install_main_path
install_log
install_main_path
install_log
install_header
install_lib
install_connector
install_examples
install_bin
install_config
echo
echo
-e
"
\0
33[44;32;1mTDengine client is installed successfully!
${
NC
}
"
...
...
@@ -191,8 +223,8 @@ function install_TDengine() {
if
[
-e
${
bin_dir
}
/taosd
]
;
then
echo
-e
"
\0
33[44;32;1mThere are already installed TDengine server, so don't need install client!
${
NC
}
"
exit
0
fi
fi
if
[
-x
${
bin_dir
}
/taos
]
;
then
update_flag
=
1
update_TDengine
...
...
packaging/tools/make_install.sh
浏览文件 @
7d815b24
...
...
@@ -9,19 +9,37 @@ set -e
# -----------------------Variables definition---------------------
source_dir
=
$1
binary_dir
=
$2
script_dir
=
$(
dirname
$(
readlink
-f
"
$0
"
))
osType
=
$3
if
[
"
$osType
"
!=
"Darwin"
]
;
then
script_dir
=
$(
dirname
$(
readlink
-f
"
$0
"
))
else
script_dir
=
${
source_dir
}
/packaging/tools
fi
# Dynamic directory
data_dir
=
"/var/lib/taos"
log_dir
=
"/var/log/taos"
if
[
"
$osType
"
!=
"Darwin"
]
;
then
log_dir
=
"/var/log/taos"
else
log_dir
=
"~/TDengineLog"
fi
data_link_dir
=
"/usr/local/taos/data"
log_link_dir
=
"/usr/local/taos/log"
cfg_install_dir
=
"/etc/taos"
bin_link_dir
=
"/usr/bin"
lib_link_dir
=
"/usr/lib"
inc_link_dir
=
"/usr/include"
if
[
"
$osType
"
!=
"Darwin"
]
;
then
bin_link_dir
=
"/usr/bin"
lib_link_dir
=
"/usr/lib"
inc_link_dir
=
"/usr/include"
else
bin_link_dir
=
"/usr/local/bin"
lib_link_dir
=
"/usr/local/lib"
inc_link_dir
=
"/usr/local/include"
fi
#install main path
install_main_dir
=
"/usr/local/taos"
...
...
@@ -43,58 +61,61 @@ if command -v sudo > /dev/null; then
csudo
=
"sudo"
fi
initd_mod
=
0
service_mod
=
2
if
pidof systemd &> /dev/null
;
then
service_mod
=
0
elif
$(
which service &> /dev/null
)
;
then
service_mod
=
1
service_config_dir
=
"/etc/init.d"
if
$(
which chkconfig &> /dev/null
)
;
then
initd_mod
=
1
elif
$(
which insserv &> /dev/null
)
;
then
initd_mod
=
2
elif
$(
which update-rc.d &> /dev/null
)
;
then
initd_mod
=
3
if
[
"
$osType
"
!=
"Darwin"
]
;
then
initd_mod
=
0
service_mod
=
2
if
pidof systemd &> /dev/null
;
then
service_mod
=
0
elif
$(
which service &> /dev/null
)
;
then
service_mod
=
1
service_config_dir
=
"/etc/init.d"
if
$(
which chkconfig &> /dev/null
)
;
then
initd_mod
=
1
elif
$(
which insserv &> /dev/null
)
;
then
initd_mod
=
2
elif
$(
which update-rc.d &> /dev/null
)
;
then
initd_mod
=
3
else
service_mod
=
2
fi
else
service_mod
=
2
fi
else
service_mod
=
2
fi
# get the operating system type for using the corresponding init file
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
osinfo
=
$(
cat
/etc/os-release |
grep
"NAME"
|
cut
-d
'"'
-f2
)
#echo "osinfo: ${osinfo}"
os_type
=
0
if
echo
$osinfo
|
grep
-qwi
"ubuntu"
;
then
echo
"this is ubuntu system"
os_type
=
1
elif
echo
$osinfo
|
grep
-qwi
"debian"
;
then
echo
"this is debian system"
os_type
=
1
elif
echo
$osinfo
|
grep
-qwi
"Kylin"
;
then
echo
"this is Kylin system"
os_type
=
1
elif
echo
$osinfo
|
grep
-qwi
"centos"
;
then
echo
"this is centos system"
os_type
=
2
elif
echo
$osinfo
|
grep
-qwi
"fedora"
;
then
echo
"this is fedora system"
os_type
=
2
else
echo
"this is other linux system"
os_type
=
0
fi
# get the operating system type for using the corresponding init file
# ubuntu/debian(deb), centos/fedora(rpm), others: opensuse, redhat, ..., no verification
#osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
osinfo
=
$(
cat
/etc/os-release |
grep
"NAME"
|
cut
-d
'"'
-f2
)
#echo "osinfo: ${osinfo}"
os_type
=
0
if
echo
$osinfo
|
grep
-qwi
"ubuntu"
;
then
echo
"this is ubuntu system"
os_type
=
1
elif
echo
$osinfo
|
grep
-qwi
"debian"
;
then
echo
"this is debian system"
os_type
=
1
elif
echo
$osinfo
|
grep
-qwi
"Kylin"
;
then
echo
"this is Kylin system"
os_type
=
1
elif
echo
$osinfo
|
grep
-qwi
"centos"
;
then
echo
"this is centos system"
os_type
=
2
elif
echo
$osinfo
|
grep
-qwi
"fedora"
;
then
echo
"this is fedora system"
os_type
=
2
else
echo
"this is other linux system"
os_type
=
0
fi
function
kill_taosd
()
{
pid
=
$(
ps
-ef
|
grep
"taosd"
|
grep
-v
"grep"
|
awk
'{print $2}'
)
if
[
-n
"
$pid
"
]
;
then
${
csudo
}
kill
-9
$pid
||
:
fi
pid
=
$(
ps
-ef
|
grep
"taosd"
|
grep
-v
"grep"
|
awk
'{print $2}'
)
if
[
-n
"
$pid
"
]
;
then
${
csudo
}
kill
-9
$pid
||
:
fi
}
function
install_main_path
()
{
...
...
@@ -107,37 +128,62 @@ function install_main_path() {
${
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
}
/init.d
if
[
"
$osType
"
!=
"Darwin"
]
;
then
${
csudo
}
mkdir
-p
${
install_main_dir
}
/init.d
fi
}
function
install_bin
()
{
# Remove links
${
csudo
}
rm
-f
${
bin_link_dir
}
/taos
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosd
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosdemo
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosdump
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/rmtaos
||
:
${
csudo
}
cp
-r
${
binary_dir
}
/build/bin/
*
${
install_main_dir
}
/bin
${
csudo
}
cp
-r
${
script_dir
}
/remove.sh
${
install_main_dir
}
/bin
${
csudo
}
rm
-f
${
bin_link_dir
}
/taos
||
:
if
[
"
$osType
"
!=
"Darwin"
]
;
then
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosd
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosdemo
||
:
${
csudo
}
rm
-f
${
bin_link_dir
}
/taosdump
||
:
fi
${
csudo
}
rm
-f
${
bin_link_dir
}
/rmtaos
||
:
${
csudo
}
cp
-r
${
binary_dir
}
/build/bin/
*
${
install_main_dir
}
/bin
if
[
"
$osType
"
!=
"Darwin"
]
;
then
${
csudo
}
cp
-r
${
script_dir
}
/remove.sh
${
install_main_dir
}
/bin
else
${
csudo
}
cp
-r
${
script_dir
}
/remove_client.sh
${
install_main_dir
}
/bin
fi
${
csudo
}
chmod
0555
${
install_main_dir
}
/bin/
*
#Make link
[
-x
${
install_main_dir
}
/bin/taos
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taos
${
bin_link_dir
}
/taos
||
:
[
-x
${
install_main_dir
}
/bin/taosd
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taosd
${
bin_link_dir
}
/taosd
||
:
[
-x
${
install_main_dir
}
/bin/taosdump
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taosdump
${
bin_link_dir
}
/taosdump
||
:
[
-x
${
install_main_dir
}
/bin/taosdemo
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taosdemo
${
bin_link_dir
}
/taosdemo
||
:
[
-x
${
install_main_dir
}
/bin/remove.sh
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/remove.sh
${
bin_link_dir
}
/rmtaos
||
:
if
[
"
$osType
"
!=
"Darwin"
]
;
then
[
-x
${
install_main_dir
}
/bin/taosd
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taosd
${
bin_link_dir
}
/taosd
||
:
[
-x
${
install_main_dir
}
/bin/taosdump
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taosdump
${
bin_link_dir
}
/taosdump
||
:
[
-x
${
install_main_dir
}
/bin/taosdemo
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/taosdemo
${
bin_link_dir
}
/taosdemo
||
:
fi
if
[
"
$osType
"
!=
"Darwin"
]
;
then
[
-x
${
install_main_dir
}
/bin/remove.sh
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/remove.sh
${
bin_link_dir
}
/rmtaos
||
:
else
[
-x
${
install_main_dir
}
/bin/remove_client.sh
]
&&
${
csudo
}
ln
-s
${
install_main_dir
}
/bin/remove_client.sh
${
bin_link_dir
}
/rmtaos
||
:
fi
}
function
install_lib
()
{
# Remove links
${
csudo
}
rm
-f
${
lib_link_dir
}
/libtaos.
*
||
:
${
csudo
}
rm
-f
${
lib_link_dir
}
/libtaos.
*
||
:
versioninfo
=
$(
${
script_dir
}
/get_version.sh
${
source_dir
}
/src/util/src/version.c
)
${
csudo
}
cp
${
binary_dir
}
/build/lib/libtaos.so.
${
versioninfo
}
${
install_main_dir
}
/driver
&&
${
csudo
}
chmod
777
${
install_main_dir
}
/driver/
*
${
csudo
}
ln
-sf
${
install_main_dir
}
/driver/libtaos.so.
${
versioninfo
}
${
lib_link_dir
}
/libtaos.so.1
${
csudo
}
ln
-sf
${
lib_link_dir
}
/libtaos.so.1
${
lib_link_dir
}
/libtaos.so
if
[
"
$osType
"
!=
"Darwin"
]
;
then
${
csudo
}
cp
${
binary_dir
}
/build/lib/libtaos.so.
${
versioninfo
}
${
install_main_dir
}
/driver
&&
${
csudo
}
chmod
777
${
install_main_dir
}
/driver/
*
${
csudo
}
ln
-sf
${
install_main_dir
}
/driver/libtaos.so.
${
versioninfo
}
${
lib_link_dir
}
/libtaos.so.1
${
csudo
}
ln
-sf
${
lib_link_dir
}
/libtaos.so.1
${
lib_link_dir
}
/libtaos.so
else
${
csudo
}
cp
${
binary_dir
}
/build/lib/libtaos.
${
versioninfo
}
.dylib
${
install_main_dir
}
/driver
&&
${
csudo
}
chmod
777
${
install_main_dir
}
/driver/
*
${
csudo
}
ln
-sf
${
install_main_dir
}
/driver/libtaos.
${
versioninfo
}
.dylib
${
lib_link_dir
}
/libtaos.1.dylib
${
csudo
}
ln
-sf
${
lib_link_dir
}
/libtaos.1.dylib
${
lib_link_dir
}
/libtaos.dylib
fi
}
function
install_header
()
{
...
...
@@ -163,8 +209,13 @@ function install_config() {
function
install_log
()
{
${
csudo
}
rm
-rf
${
log_dir
}
||
:
${
csudo
}
mkdir
-p
${
log_dir
}
&&
${
csudo
}
chmod
777
${
log_dir
}
if
[
"
$osType
"
!=
"Darwin"
]
;
then
${
csudo
}
mkdir
-p
${
log_dir
}
&&
${
csudo
}
chmod
777
${
log_dir
}
else
mkdir
-p
${
log_dir
}
&&
chmod
777
${
log_dir
}
fi
${
csudo
}
ln
-s
${
log_dir
}
${
install_main_dir
}
/log
}
...
...
@@ -291,7 +342,9 @@ function install_service() {
function
update_TDengine
()
{
echo
-e
"
${
GREEN
}
Start to update TDEngine...
${
NC
}
"
# Stop the service if running
if
pidof taosd &> /dev/null
;
then
if
[
"
$osType
"
!=
"Darwin"
]
;
then
if
pidof taosd &> /dev/null
;
then
if
((
${
service_mod
}
==
0
))
;
then
${
csudo
}
systemctl stop taosd
||
:
elif
((
${
service_mod
}
==
1
))
;
then
...
...
@@ -300,6 +353,7 @@ function update_TDengine() {
kill_taosd
fi
sleep
1
fi
fi
install_main_path
...
...
@@ -310,32 +364,54 @@ function update_TDengine() {
install_connector
install_examples
install_bin
install_service
if
[
"
$osType
"
!=
"Darwin"
]
;
then
install_service
fi
install_config
echo
echo
-e
"
\0
33[44;32;1mTDengine is updated successfully!
${
NC
}
"
echo
echo
-e
"
${
GREEN_DARK
}
To configure TDengine
${
NC
}
: edit /etc/taos/taos.cfg"
if
((
${
service_mod
}
==
0
))
;
then
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
:
${
csudo
}
systemctl start taosd
${
NC
}
"
elif
((
${
service_mod
}
==
1
))
;
then
if
[
"
$osType
"
!=
"Darwin"
]
;
then
echo
echo
-e
"
\0
33[44;32;1mTDengine is updated successfully!
${
NC
}
"
echo
echo
-e
"
${
GREEN_DARK
}
To configure TDengine
${
NC
}
: edit /etc/taos/taos.cfg"
if
((
${
service_mod
}
==
0
))
;
then
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
:
${
csudo
}
systemctl start taosd
${
NC
}
"
elif
((
${
service_mod
}
==
1
))
;
then
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
:
${
csudo
}
service taosd start
${
NC
}
"
else
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
: ./taosd
${
NC
}
"
fi
else
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
: ./taosd
${
NC
}
"
fi
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
echo
echo
-e
"
\0
33[44;32;1mTDengine is updated successfully!
${
NC
}
"
else
echo
echo
-e
"
\0
33[44;32;1mTDengine Client is updated successfully!
${
NC
}
"
echo
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
echo
echo
-e
"
\0
33[44;32;1mTDengine is updated successfully!
${
NC
}
"
echo
-e
"
${
GREEN_DARK
}
To access TDengine Client
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
echo
echo
-e
"
\0
33[44;32;1mTDengine Client is updated successfully!
${
NC
}
"
fi
}
function
install_TDengine
()
{
# Start to install
echo
-e
"
${
GREEN
}
Start to install TDEngine...
${
NC
}
"
if
[
"
$osType
"
!=
"Darwin"
]
;
then
echo
-e
"
${
GREEN
}
Start to install TDEngine...
${
NC
}
"
else
echo
-e
"
${
GREEN
}
Start to install TDEngine Client ...
${
NC
}
"
fi
install_main_path
install_data
if
[
"
$osType
"
!=
"Darwin"
]
;
then
install_data
fi
install_log
install_header
install_lib
...
...
@@ -343,30 +419,41 @@ function install_TDengine() {
install_examples
install_bin
install_service
if
[
"
$osType
"
!=
"Darwin"
]
;
then
install_service
fi
install_config
# Ask if to start the service
echo
echo
-e
"
\0
33[44;32;1mTDengine is installed successfully!
${
NC
}
"
echo
echo
-e
"
${
GREEN_DARK
}
To configure TDengine
${
NC
}
: edit /etc/taos/taos.cfg"
if
((
${
service_mod
}
==
0
))
;
then
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
:
${
csudo
}
systemctl start taosd
${
NC
}
"
elif
((
${
service_mod
}
==
1
))
;
then
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
:
${
csudo
}
service taosd start
${
NC
}
"
if
[
"
$osType
"
!=
"Darwin"
]
;
then
# Ask if to start the service
echo
echo
-e
"
\0
33[44;32;1mTDengine is installed successfully!
${
NC
}
"
echo
echo
-e
"
${
GREEN_DARK
}
To configure TDengine
${
NC
}
: edit /etc/taos/taos.cfg"
if
((
${
service_mod
}
==
0
))
;
then
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
:
${
csudo
}
systemctl start taosd
${
NC
}
"
elif
((
${
service_mod
}
==
1
))
;
then
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
:
${
csudo
}
service taosd start
${
NC
}
"
else
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
: ./taosd
${
NC
}
"
fi
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
echo
echo
-e
"
\0
33[44;32;1mTDengine is installed successfully!
${
NC
}
"
else
echo
-e
"
${
GREEN_DARK
}
To start TDengine
${
NC
}
: ./taosd
${
NC
}
"
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
echo
echo
-e
"
\0
33[44;32;1mTDengine Client is installed successfully!
${
NC
}
"
fi
echo
-e
"
${
GREEN_DARK
}
To access TDengine
${
NC
}
: use
${
GREEN_UNDERLINE
}
taos
${
NC
}
in shell
${
NC
}
"
echo
echo
-e
"
\0
33[44;32;1mTDengine is installed successfully!
${
NC
}
"
}
## ==============================Main program starts from here============================
echo source
directory:
$1
echo
binary directory:
$2
if
[
-x
${
bin_dir
}
/taos
d
]
;
then
if
[
-x
${
bin_dir
}
/taos
]
;
then
update_TDengine
else
install_TDengine
...
...
packaging/tools/makeclient.sh
浏览文件 @
7d815b24
...
...
@@ -13,8 +13,15 @@ osType=$5
verMode
=
$6
verType
=
$7
script_dir
=
"
$(
dirname
$(
readlink
-f
$0
))
"
top_dir
=
"
$(
readlink
-f
${
script_dir
}
/../..
)
"
if
[
"
$osType
"
!=
"Darwin"
]
;
then
script_dir
=
"
$(
dirname
$(
readlink
-f
$0
))
"
top_dir
=
"
$(
readlink
-f
${
script_dir
}
/../..
)
"
else
script_dir
=
`
dirname
$0
`
cd
${
script_dir
}
script_dir
=
"
$(
pwd
)
"
top_dir
=
${
script_dir
}
/../..
fi
# create compressed install file.
build_dir
=
"
${
compile_dir
}
/build"
...
...
@@ -22,13 +29,26 @@ code_dir="${top_dir}/src"
release_dir
=
"
${
top_dir
}
/release"
#package_name='linux'
install_dir
=
"
${
release_dir
}
/TDengine-client"
if
[
"
$verMode
"
==
"cluster"
]
;
then
install_dir
=
"
${
release_dir
}
/TDengine-enterprise-client"
else
install_dir
=
"
${
release_dir
}
/TDengine-client"
fi
# Directories and files.
bin_files
=
"
${
build_dir
}
/bin/taos
${
build_dir
}
/bin/taosdump
${
script_dir
}
/remove_client.sh"
lib_files
=
"
${
build_dir
}
/lib/libtaos.so.
${
version
}
"
if
[
"
$osType
"
!=
"Darwin"
]
;
then
bin_files
=
"
${
build_dir
}
/bin/taos
${
build_dir
}
/bin/taosdump
${
script_dir
}
/remove_client.sh"
lib_files
=
"
${
build_dir
}
/lib/libtaos.so.
${
version
}
"
else
bin_files
=
"
${
build_dir
}
/bin/taos
${
script_dir
}
/remove_client.sh"
lib_files
=
"
${
build_dir
}
/lib/libtaos.
${
version
}
.dylib"
fi
header_files
=
"
${
code_dir
}
/inc/taos.h
${
code_dir
}
/inc/taoserror.h"
cfg_dir
=
"
${
top_dir
}
/packaging/cfg"
install_files
=
"
${
script_dir
}
/install_client.sh"
# make directories.
...
...
@@ -38,10 +58,23 @@ mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/taos.cfg ${install_dir}/cfg/taos.cf
mkdir
-p
${
install_dir
}
/bin
&&
cp
${
bin_files
}
${
install_dir
}
/bin
&&
chmod
a+x
${
install_dir
}
/bin/
*
cd
${
install_dir
}
tar
-zcv
-f
taos.tar.gz
*
--remove-files
||
:
if
[
"
$osType
"
!=
"Darwin"
]
;
then
tar
-zcv
-f
taos.tar.gz
*
--remove-files
||
:
else
tar
-zcv
-f
taos.tar.gz
*
||
:
mv
taos.tar.gz ..
rm
-rf
./
*
mv
../taos.tar.gz
.
fi
cd
${
curr_dir
}
cp
${
install_files
}
${
install_dir
}
&&
chmod
a+x
${
install_dir
}
/install
*
cp
${
install_files
}
${
install_dir
}
if
[
"
$osType
"
==
"Darwin"
]
;
then
sed
's/osType=Linux/osType=Darwin/g'
${
install_dir
}
/install_client.sh
>>
install_client_temp.sh
mv
install_client_temp.sh
${
install_dir
}
/install_client.sh
fi
chmod
a+x
${
install_dir
}
/install_client.sh
# Copy example code
mkdir
-p
${
install_dir
}
/examples
...
...
@@ -60,7 +93,10 @@ cp ${lib_files} ${install_dir}/driver
# Copy connector
connector_dir
=
"
${
code_dir
}
/connector"
mkdir
-p
${
install_dir
}
/connector
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
if
[
"
$osType
"
!=
"Darwin"
]
;
then
cp
${
build_dir
}
/lib/
*
.jar
${
install_dir
}
/connector
fi
cp
-r
${
connector_dir
}
/grafana
${
install_dir
}
/connector/
cp
-r
${
connector_dir
}
/python
${
install_dir
}
/connector/
cp
-r
${
connector_dir
}
/go
${
install_dir
}
/connector
...
...
@@ -90,6 +126,13 @@ else
exit
1
fi
tar
-zcv
-f
"
$(
basename
${
pkg_name
}
)
.tar.gz"
$(
basename
${
install_dir
}
)
--remove-files
if
[
"
$osType
"
!=
"Darwin"
]
;
then
tar
-zcv
-f
"
$(
basename
${
pkg_name
}
)
.tar.gz"
$(
basename
${
install_dir
}
)
--remove-files
||
:
else
tar
-zcv
-f
"
$(
basename
${
pkg_name
}
)
.tar.gz"
$(
basename
${
install_dir
}
)
||
:
mv
"
$(
basename
${
pkg_name
}
)
.tar.gz"
..
rm
-rf
./
*
mv
../
"
$(
basename
${
pkg_name
}
)
.tar.gz"
.
fi
cd
${
curr_dir
}
packaging/tools/makepkg.sh
浏览文件 @
7d815b24
...
...
@@ -23,7 +23,11 @@ code_dir="${top_dir}/src"
release_dir
=
"
${
top_dir
}
/release"
#package_name='linux'
install_dir
=
"
${
release_dir
}
/TDengine-server"
if
[
"
$verMode
"
==
"cluster"
]
;
then
install_dir
=
"
${
release_dir
}
/TDengine-enterprise-server"
else
install_dir
=
"
${
release_dir
}
/TDengine-server"
fi
# Directories and files.
bin_files
=
"
${
build_dir
}
/bin/taosd
${
build_dir
}
/bin/taos
${
build_dir
}
/bin/taosdemo
${
build_dir
}
/bin/taosdump
${
script_dir
}
/remove.sh"
...
...
@@ -31,6 +35,7 @@ lib_files="${build_dir}/lib/libtaos.so.${version}"
header_files
=
"
${
code_dir
}
/inc/taos.h
${
code_dir
}
/inc/taoserror.h"
cfg_dir
=
"
${
top_dir
}
/packaging/cfg"
install_files
=
"
${
script_dir
}
/install.sh"
nginx_dir
=
"
${
code_dir
}
/../../enterprise/src/modules/web"
# Init file
#init_dir=${script_dir}/deb
...
...
@@ -50,11 +55,29 @@ mkdir -p ${install_dir}/bin && cp ${bin_files} ${install_dir}/bin && chmod a+x $
mkdir
-p
${
install_dir
}
/init.d
&&
cp
${
init_file_deb
}
${
install_dir
}
/init.d/taosd.deb
mkdir
-p
${
install_dir
}
/init.d
&&
cp
${
init_file_rpm
}
${
install_dir
}
/init.d/taosd.rpm
if
[
"
$verMode
"
==
"cluster"
]
;
then
mkdir
-p
${
install_dir
}
/nginxd
&&
cp
-r
${
nginx_dir
}
/
*
${
install_dir
}
/nginxd
cp
${
nginx_dir
}
/png/taos.png
${
install_dir
}
/nginxd/admin/images/taos.png
rm
-rf
${
install_dir
}
/nginxd/png
if
[
"
$cpuType
"
==
"aarch64"
]
;
then
cp
-f
${
install_dir
}
/nginxd/sbin/arm/64bit/nginx
${
install_dir
}
/nginxd/sbin/
elif
[
"
$cpuType
"
==
"aarch32"
]
;
then
cp
-f
${
install_dir
}
/nginxd/sbin/arm/32bit/nginx
${
install_dir
}
/nginxd/sbin/
fi
rm
-rf
${
install_dir
}
/nginxd/sbin/arm
fi
cd
${
install_dir
}
tar
-zcv
-f
taos.tar.gz
*
--remove-files
||
:
tar
-zcv
-f
taos.tar.gz
*
--remove-files
||
:
cd
${
curr_dir
}
cp
${
install_files
}
${
install_dir
}
&&
chmod
a+x
${
install_dir
}
/install
*
cp
${
install_files
}
${
install_dir
}
if
[
"
$verMode
"
==
"cluster"
]
;
then
sed
's/verMode=lite/verMode=cluster/g'
${
install_dir
}
/install.sh
>>
install_temp.sh
mv
install_temp.sh
${
install_dir
}
/install.sh
fi
chmod
a+x
${
install_dir
}
/install.sh
# Copy example code
mkdir
-p
${
install_dir
}
/examples
...
...
@@ -103,6 +126,6 @@ else
exit
1
fi
tar
-zcv
-f
"
$(
basename
${
pkg_name
}
)
.tar.gz"
$(
basename
${
install_dir
}
)
--remove-files
tar
-zcv
-f
"
$(
basename
${
pkg_name
}
)
.tar.gz"
$(
basename
${
install_dir
}
)
--remove-files
||
:
cd
${
curr_dir
}
cd
${
curr_dir
}
\ No newline at end of file
packaging/tools/remove.sh
浏览文件 @
7d815b24
...
...
@@ -2,6 +2,11 @@
#
# Script to stop the service and uninstall TDengine, but retain the config, data and log files.
set
-e
#set -x
verMode
=
lite
RED
=
'\033[0;31m'
GREEN
=
'\033[1;32m'
NC
=
'\033[0m'
...
...
@@ -14,10 +19,14 @@ cfg_link_dir="/usr/local/taos/cfg"
bin_link_dir
=
"/usr/bin"
lib_link_dir
=
"/usr/lib"
inc_link_dir
=
"/usr/include"
install_nginxd_dir
=
"/usr/local/nginxd"
# v1.5 jar dir
v15_java_app_dir
=
"/usr/local/lib/taos"
service_config_dir
=
"/etc/systemd/system"
taos_service_name
=
"taosd"
nginx_service_name
=
"nginxd"
csudo
=
""
if
command
-v
sudo
>
/dev/null
;
then
csudo
=
"sudo"
...
...
@@ -62,6 +71,7 @@ function clean_bin() {
function
clean_lib
()
{
# Remove link
${
csudo
}
rm
-f
${
lib_link_dir
}
/libtaos.
*
||
:
${
csudo
}
rm
-rf
${
v15_java_app_dir
}
||
:
}
function
clean_header
()
{
...
...
@@ -90,6 +100,20 @@ function clean_service_on_systemd() {
${
csudo
}
systemctl disable
${
taos_service_name
}
&> /dev/null
||
echo
&> /dev/null
${
csudo
}
rm
-f
${
taosd_service_config
}
if
[
"
$verMode
"
==
"cluster"
]
;
then
nginx_service_config
=
"
${
service_config_dir
}
/
${
nginx_service_name
}
.service"
if
[
-d
${
bin_dir
}
/web
]
;
then
if
systemctl is-active
--quiet
${
nginx_service_name
}
;
then
echo
"Nginx for TDengine is running, stopping it..."
${
csudo
}
systemctl stop
${
nginx_service_name
}
&> /dev/null
||
echo
&> /dev/null
fi
${
csudo
}
systemctl disable
${
nginx_service_name
}
&> /dev/null
||
echo
&> /dev/null
${
csudo
}
rm
-f
${
nginx_service_config
}
fi
fi
}
function
clean_service_on_sysvinit
()
{
...
...
@@ -143,6 +167,7 @@ clean_config
${
csudo
}
rm
-rf
${
data_link_dir
}
||
:
${
csudo
}
rm
-rf
${
install_main_dir
}
${
csudo
}
rm
-rf
${
install_nginxd_dir
}
osinfo
=
$(
awk
-F
=
'/^NAME/{print $2}'
/etc/os-release
)
if
echo
$osinfo
|
grep
-qwi
"ubuntu"
;
then
...
...
packaging/tools/remove_client.sh
浏览文件 @
7d815b24
...
...
@@ -17,6 +17,10 @@ bin_link_dir="/usr/bin"
lib_link_dir
=
"/usr/lib"
inc_link_dir
=
"/usr/include"
# v1.5 jar dir
v15_java_app_dir
=
"/usr/local/lib/taos"
csudo
=
""
if
command
-v
sudo
>
/dev/null
;
then
csudo
=
"sudo"
...
...
@@ -39,6 +43,7 @@ function clean_bin() {
function
clean_lib
()
{
# Remove link
${
csudo
}
rm
-f
${
lib_link_dir
}
/libtaos.
*
||
:
${
csudo
}
rm
-rf
${
v15_java_app_dir
}
||
:
}
function
clean_header
()
{
...
...
src/client/CMakeLists.txt
浏览文件 @
7d815b24
...
...
@@ -24,20 +24,10 @@ IF ((TD_LINUX_64) OR (TD_LINUX_32 AND TD_ARM))
#set version of .so
#VERSION so version
#SOVERSION api version
IF
(
TD_LITE
)
execute_process
(
COMMAND chmod 777
${
TD_COMMUNITY_DIR
}
/packaging/tools/get_version.sh
)
execute_process
(
COMMAND
${
TD_COMMUNITY_DIR
}
/packaging/tools/get_version.sh
${
TD_COMMUNITY_DIR
}
/src/util/src/version.c
OUTPUT_VARIABLE
VERSION_INFO
)
MESSAGE
(
STATUS
"build lite version
${
VERSION_INFO
}
"
)
ELSE
()
execute_process
(
COMMAND chmod 777
${
TD_COMMUNITY_DIR
}
/packaging/tools/get_version.sh
)
execute_process
(
COMMAND
${
TD_COMMUNITY_DIR
}
/packaging/tools/get_version.sh
${
TD_COMMUNITY_DIR
}
/src/util/src/version.c
OUTPUT_VARIABLE
VERSION_INFO
)
MESSAGE
(
STATUS
"build cluster version
${
VERSION_INFO
}
"
)
ENDIF
()
execute_process
(
COMMAND chmod 777
${
TD_COMMUNITY_DIR
}
/packaging/tools/get_version.sh
)
execute_process
(
COMMAND
${
TD_COMMUNITY_DIR
}
/packaging/tools/get_version.sh
${
TD_COMMUNITY_DIR
}
/src/util/src/version.c
OUTPUT_VARIABLE
VERSION_INFO
)
MESSAGE
(
STATUS
"build version
${
VERSION_INFO
}
"
)
SET_TARGET_PROPERTIES
(
taos PROPERTIES VERSION
${
VERSION_INFO
}
SOVERSION 1
)
...
...
@@ -57,6 +47,7 @@ ELSEIF (TD_WINDOWS_64)
TARGET_LINK_LIBRARIES
(
taos trpc
)
ELSEIF
(
TD_DARWIN_64
)
SET
(
CMAKE_MACOSX_RPATH 1
)
INCLUDE_DIRECTORIES
(
${
TD_COMMUNITY_DIR
}
/deps/jni/linux
)
ADD_LIBRARY
(
taos_static STATIC
${
SRC
}
)
...
...
@@ -66,6 +57,17 @@ ELSEIF (TD_DARWIN_64)
# generate dynamic library (*.dylib)
ADD_LIBRARY
(
taos SHARED
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
taos trpc tutil pthread m
)
SET_TARGET_PROPERTIES
(
taos PROPERTIES CLEAN_DIRECT_OUTPUT 1
)
#set version of .so
#VERSION so version
#SOVERSION api version
execute_process
(
COMMAND chmod 777
${
TD_COMMUNITY_DIR
}
/packaging/tools/get_version.sh
)
execute_process
(
COMMAND
${
TD_COMMUNITY_DIR
}
/packaging/tools/get_version.sh
${
TD_COMMUNITY_DIR
}
/src/util/src/version.c
OUTPUT_VARIABLE
VERSION_INFO
)
MESSAGE
(
STATUS
"build version
${
VERSION_INFO
}
"
)
SET_TARGET_PROPERTIES
(
taos PROPERTIES VERSION
${
VERSION_INFO
}
SOVERSION 1
)
ENDIF
()
src/client/src/tscServer.c
浏览文件 @
7d815b24
...
...
@@ -774,10 +774,10 @@ int tscProcessSql(SSqlObj *pSql) {
}
}
sem_post
(
&
pSql
->
emptyRspSem
);
sem_wait
(
&
pSql
->
rspSem
);
t
sem_post
(
&
pSql
->
emptyRspSem
);
t
sem_wait
(
&
pSql
->
rspSem
);
sem_post
(
&
pSql
->
emptyRspSem
);
t
sem_post
(
&
pSql
->
emptyRspSem
);
if
(
pSql
->
numOfSubs
<=
0
)
{
pSql
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
...
...
@@ -810,9 +810,9 @@ int tscProcessSql(SSqlObj *pSql) {
}
if
(
fp
==
NULL
)
{
sem_post
(
&
pSql
->
emptyRspSem
);
sem_wait
(
&
pSql
->
rspSem
);
sem_post
(
&
pSql
->
emptyRspSem
);
t
sem_post
(
&
pSql
->
emptyRspSem
);
t
sem_wait
(
&
pSql
->
rspSem
);
t
sem_post
(
&
pSql
->
emptyRspSem
);
// set the command flag must be after the semaphore been correctly set.
pSql
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_METRIC
;
...
...
src/kit/shell/CMakeLists.txt
浏览文件 @
7d815b24
...
...
@@ -9,6 +9,7 @@ INCLUDE_DIRECTORIES(inc)
IF
((
TD_LINUX_64
)
OR
(
TD_LINUX_32 AND TD_ARM
))
AUX_SOURCE_DIRECTORY
(
./src SRC
)
LIST
(
REMOVE_ITEM SRC ./src/shellWindows.c
)
LIST
(
REMOVE_ITEM SRC ./src/shellDarwin.c
)
ADD_EXECUTABLE
(
shell
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
shell taos_static
)
SET_TARGET_PROPERTIES
(
shell PROPERTIES OUTPUT_NAME taos
)
...
...
@@ -24,7 +25,9 @@ ELSEIF (TD_WINDOWS_64)
ELSEIF
(
TD_DARWIN_64
)
LIST
(
APPEND SRC ./src/shellEngine.c
)
LIST
(
APPEND SRC ./src/shellMain.c
)
LIST
(
APPEND SRC ./src/shellWindows.c
)
LIST
(
APPEND SRC ./src/shellDarwin.c
)
LIST
(
APPEND SRC ./src/shellCommand.c
)
LIST
(
APPEND SRC ./src/shellImport.c
)
ADD_EXECUTABLE
(
shell
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
shell taos_static
)
SET_TARGET_PROPERTIES
(
shell PROPERTIES OUTPUT_NAME taos
)
...
...
src/kit/shell/src/shellDarwin.c
0 → 100644
浏览文件 @
7d815b24
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define __USE_XOPEN
#include "os.h"
#include "shell.h"
#include "shellCommand.h"
#include "tkey.h"
#define OPT_ABORT 1
/* �Cabort */
int
indicator
=
1
;
struct
termios
oldtio
;
extern
int
wcwidth
(
wchar_t
c
);
void
insertChar
(
Command
*
cmd
,
char
*
c
,
int
size
);
void
printHelp
()
{
char
indent
[
10
]
=
" "
;
printf
(
"taos shell is used to test the TDEngine database
\n
"
);
printf
(
"%s%s
\n
"
,
indent
,
"-h"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"TDEngine server IP address to connect. The default host is localhost."
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The password to use when connecting to the server."
);
printf
(
"%s%s
\n
"
,
indent
,
"-P"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The TCP/IP port number to use for the connection"
);
printf
(
"%s%s
\n
"
,
indent
,
"-u"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The TDEngine user name to use when connecting to the server."
);
printf
(
"%s%s
\n
"
,
indent
,
"-c"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Configuration directory."
);
printf
(
"%s%s
\n
"
,
indent
,
"-s"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Commands to run without enter the shell."
);
printf
(
"%s%s
\n
"
,
indent
,
"-r"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Output time as unsigned long.."
);
printf
(
"%s%s
\n
"
,
indent
,
"-f"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Script to run without enter the shell."
);
printf
(
"%s%s
\n
"
,
indent
,
"-d"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Database to use when connecting to the server."
);
printf
(
"%s%s
\n
"
,
indent
,
"-t"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Time zone of the shell, default is local."
);
printf
(
"%s%s
\n
"
,
indent
,
"-D"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Use multi-thread to import all SQL files in the directory separately."
);
printf
(
"%s%s
\n
"
,
indent
,
"-T"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Number of threads when using multi-thread to import data."
);
exit
(
EXIT_SUCCESS
);
}
void
shellParseArgument
(
int
argc
,
char
*
argv
[],
struct
arguments
*
arguments
)
{
wordexp_t
full_path
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
// for host
if
(
strcmp
(
argv
[
i
],
"-h"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
arguments
->
host
=
argv
[
++
i
];
}
else
{
fprintf
(
stderr
,
"option -h requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
// for password
else
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
)
{
arguments
->
is_use_passwd
=
true
;
}
// for management port
else
if
(
strcmp
(
argv
[
i
],
"-P"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
tsMgmtShellPort
=
atoi
(
argv
[
++
i
]);
}
else
{
fprintf
(
stderr
,
"option -P requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
// for user
else
if
(
strcmp
(
argv
[
i
],
"-u"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
arguments
->
user
=
argv
[
++
i
];
}
else
{
fprintf
(
stderr
,
"option -u requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
strcpy
(
configDir
,
argv
[
++
i
]);
}
else
{
fprintf
(
stderr
,
"Option -c requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-s"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
arguments
->
commands
=
argv
[
++
i
];
}
else
{
fprintf
(
stderr
,
"option -s requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-r"
)
==
0
)
{
arguments
->
is_raw_time
=
true
;
}
// For temperory batch commands to run TODO
else
if
(
strcmp
(
argv
[
i
],
"-f"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
strcpy
(
arguments
->
file
,
argv
[
++
i
]);
}
else
{
fprintf
(
stderr
,
"option -f requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
// for default database
else
if
(
strcmp
(
argv
[
i
],
"-d"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
arguments
->
database
=
argv
[
++
i
];
}
else
{
fprintf
(
stderr
,
"option -d requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
// For time zone
else
if
(
strcmp
(
argv
[
i
],
"-t"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
arguments
->
timezone
=
argv
[
++
i
];
}
else
{
fprintf
(
stderr
,
"option -t requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
// For import directory
else
if
(
strcmp
(
argv
[
i
],
"-D"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
if
(
wordexp
(
argv
[
++
i
],
&
full_path
,
0
)
!=
0
)
{
fprintf
(
stderr
,
"Invalid path %s
\n
"
,
argv
[
i
]);
exit
(
EXIT_FAILURE
);
}
strcpy
(
arguments
->
dir
,
full_path
.
we_wordv
[
0
]);
wordfree
(
&
full_path
);
}
else
{
fprintf
(
stderr
,
"option -D requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
// For time zone
else
if
(
strcmp
(
argv
[
i
],
"-T"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
arguments
->
threadNum
=
atoi
(
argv
[
++
i
]);
}
else
{
fprintf
(
stderr
,
"option -T requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
// For temperory command TODO
else
if
(
strcmp
(
argv
[
i
],
"--help"
)
==
0
)
{
printHelp
();
exit
(
EXIT_FAILURE
);
}
else
{
fprintf
(
stderr
,
"wrong options
\n
"
);
printHelp
();
exit
(
EXIT_FAILURE
);
}
}
}
void
shellReadCommand
(
TAOS
*
con
,
char
*
command
)
{
unsigned
hist_counter
=
history
.
hend
;
char
utf8_array
[
10
]
=
"
\0
"
;
Command
cmd
;
memset
(
&
cmd
,
0
,
sizeof
(
cmd
));
cmd
.
buffer
=
(
char
*
)
calloc
(
1
,
MAX_COMMAND_SIZE
);
cmd
.
command
=
(
char
*
)
calloc
(
1
,
MAX_COMMAND_SIZE
);
showOnScreen
(
&
cmd
);
// Read input.
char
c
;
while
(
1
)
{
c
=
getchar
();
if
(
c
<
0
)
{
// For UTF-8
int
count
=
countPrefixOnes
(
c
);
utf8_array
[
0
]
=
c
;
for
(
int
k
=
1
;
k
<
count
;
k
++
)
{
c
=
getchar
();
utf8_array
[
k
]
=
c
;
}
insertChar
(
&
cmd
,
utf8_array
,
count
);
}
else
if
(
c
<
'\033'
)
{
// Ctrl keys. TODO: Implement ctrl combinations
switch
(
c
)
{
case
1
:
// ctrl A
positionCursorHome
(
&
cmd
);
break
;
case
3
:
printf
(
"
\n
"
);
resetCommand
(
&
cmd
,
""
);
kill
(
0
,
SIGINT
);
break
;
case
4
:
// EOF or Ctrl+D
printf
(
"
\n
"
);
taos_close
(
con
);
// write the history
write_history
();
exitShell
();
break
;
case
5
:
// ctrl E
positionCursorEnd
(
&
cmd
);
break
;
case
8
:
backspaceChar
(
&
cmd
);
break
;
case
'\n'
:
case
'\r'
:
printf
(
"
\n
"
);
if
(
isReadyGo
(
&
cmd
))
{
sprintf
(
command
,
"%s%s"
,
cmd
.
buffer
,
cmd
.
command
);
tfree
(
cmd
.
buffer
);
tfree
(
cmd
.
command
);
return
;
}
else
{
updateBuffer
(
&
cmd
);
}
break
;
case
12
:
// Ctrl + L;
system
(
"clear"
);
showOnScreen
(
&
cmd
);
break
;
}
}
else
if
(
c
==
'\033'
)
{
c
=
getchar
();
switch
(
c
)
{
case
'['
:
c
=
getchar
();
switch
(
c
)
{
case
'A'
:
// Up arrow
if
(
hist_counter
!=
history
.
hstart
)
{
hist_counter
=
(
hist_counter
+
MAX_HISTORY_SIZE
-
1
)
%
MAX_HISTORY_SIZE
;
resetCommand
(
&
cmd
,
(
history
.
hist
[
hist_counter
]
==
NULL
)
?
""
:
history
.
hist
[
hist_counter
]);
}
break
;
case
'B'
:
// Down arrow
if
(
hist_counter
!=
history
.
hend
)
{
int
next_hist
=
(
hist_counter
+
1
)
%
MAX_HISTORY_SIZE
;
if
(
next_hist
!=
history
.
hend
)
{
resetCommand
(
&
cmd
,
(
history
.
hist
[
next_hist
]
==
NULL
)
?
""
:
history
.
hist
[
next_hist
]);
}
else
{
resetCommand
(
&
cmd
,
""
);
}
hist_counter
=
next_hist
;
}
break
;
case
'C'
:
// Right arrow
moveCursorRight
(
&
cmd
);
break
;
case
'D'
:
// Left arrow
moveCursorLeft
(
&
cmd
);
break
;
case
'1'
:
if
((
c
=
getchar
())
==
'~'
)
{
// Home key
positionCursorHome
(
&
cmd
);
}
break
;
case
'2'
:
if
((
c
=
getchar
())
==
'~'
)
{
// Insert key
}
break
;
case
'3'
:
if
((
c
=
getchar
())
==
'~'
)
{
// Delete key
deleteChar
(
&
cmd
);
}
break
;
case
'4'
:
if
((
c
=
getchar
())
==
'~'
)
{
// End key
positionCursorEnd
(
&
cmd
);
}
break
;
case
'5'
:
if
((
c
=
getchar
())
==
'~'
)
{
// Page up key
}
break
;
case
'6'
:
if
((
c
=
getchar
())
==
'~'
)
{
// Page down key
}
break
;
case
72
:
// Home key
positionCursorHome
(
&
cmd
);
break
;
case
70
:
// End key
positionCursorEnd
(
&
cmd
);
break
;
}
break
;
}
}
else
if
(
c
==
0x7f
)
{
// press delete key
backspaceChar
(
&
cmd
);
}
else
{
insertChar
(
&
cmd
,
&
c
,
1
);
}
}
}
void
*
shellLoopQuery
(
void
*
arg
)
{
if
(
indicator
)
{
get_old_terminal_mode
(
&
oldtio
);
indicator
=
0
;
}
TAOS
*
con
=
(
TAOS
*
)
arg
;
pthread_cleanup_push
(
cleanup_handler
,
NULL
);
char
*
command
=
malloc
(
MAX_COMMAND_SIZE
);
if
(
command
==
NULL
){
tscError
(
"failed to malloc command"
);
return
NULL
;
}
while
(
1
)
{
// Read command from shell.
memset
(
command
,
0
,
MAX_COMMAND_SIZE
);
set_terminal_mode
();
shellReadCommand
(
con
,
command
);
reset_terminal_mode
();
// Run the command
shellRunCommand
(
con
,
command
);
}
pthread_cleanup_pop
(
1
);
return
NULL
;
}
void
shellPrintNChar
(
char
*
str
,
int
width
,
bool
printMode
)
{
int
col_left
=
width
;
wchar_t
wc
;
while
(
col_left
>
0
)
{
if
(
*
str
==
'\0'
)
break
;
char
*
tstr
=
str
;
int
byte_width
=
mbtowc
(
&
wc
,
tstr
,
MB_CUR_MAX
);
if
(
byte_width
<=
0
)
break
;
int
col_width
=
wcwidth
(
wc
);
if
(
col_width
<=
0
)
{
str
+=
byte_width
;
continue
;
}
if
(
col_left
<
col_width
)
break
;
printf
(
"%lc"
,
wc
);
str
+=
byte_width
;
col_left
-=
col_width
;
}
while
(
col_left
>
0
)
{
printf
(
" "
);
col_left
--
;
}
if
(
!
printMode
)
{
printf
(
"|"
);
}
else
{
printf
(
"
\n
"
);
}
}
int
get_old_terminal_mode
(
struct
termios
*
tio
)
{
/* Make sure stdin is a terminal. */
if
(
!
isatty
(
STDIN_FILENO
))
{
return
-
1
;
}
// Get the parameter of current terminal
if
(
tcgetattr
(
0
,
&
oldtio
)
!=
0
)
{
return
-
1
;
}
return
1
;
}
void
reset_terminal_mode
()
{
if
(
tcsetattr
(
0
,
TCSANOW
,
&
oldtio
)
!=
0
)
{
fprintf
(
stderr
,
"Fail to reset the terminal properties!
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
void
set_terminal_mode
()
{
struct
termios
newtio
;
/* if (atexit(reset_terminal_mode) != 0) { */
/* fprintf(stderr, "Error register exit function!\n"); */
/* exit(EXIT_FAILURE); */
/* } */
memcpy
(
&
newtio
,
&
oldtio
,
sizeof
(
oldtio
));
// Set new terminal attributes.
newtio
.
c_iflag
&=
~
(
IXON
|
IXOFF
|
ICRNL
|
INLCR
|
IGNCR
|
IMAXBEL
|
ISTRIP
);
newtio
.
c_iflag
|=
IGNBRK
;
// newtio.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONLRET);
newtio
.
c_oflag
|=
OPOST
;
newtio
.
c_oflag
|=
ONLCR
;
newtio
.
c_oflag
&=
~
(
OCRNL
|
ONLRET
);
newtio
.
c_lflag
&=
~
(
IEXTEN
|
ICANON
|
ECHO
|
ECHOE
|
ECHONL
|
ECHOCTL
|
ECHOPRT
|
ECHOKE
|
ISIG
);
newtio
.
c_cc
[
VMIN
]
=
1
;
newtio
.
c_cc
[
VTIME
]
=
0
;
if
(
tcsetattr
(
0
,
TCSANOW
,
&
newtio
)
!=
0
)
{
fprintf
(
stderr
,
"Fail to set terminal properties!
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
void
get_history_path
(
char
*
history
)
{
sprintf
(
history
,
"%s/%s"
,
getpwuid
(
getuid
())
->
pw_dir
,
HISTORY_FILE
);
}
void
clearScreen
(
int
ecmd_pos
,
int
cursor_pos
)
{
struct
winsize
w
;
ioctl
(
0
,
TIOCGWINSZ
,
&
w
);
int
cursor_x
=
cursor_pos
/
w
.
ws_col
;
int
cursor_y
=
cursor_pos
%
w
.
ws_col
;
int
command_x
=
ecmd_pos
/
w
.
ws_col
;
positionCursor
(
cursor_y
,
LEFT
);
positionCursor
(
command_x
-
cursor_x
,
DOWN
);
fprintf
(
stdout
,
"
\033
[2K"
);
for
(
int
i
=
0
;
i
<
command_x
;
i
++
)
{
positionCursor
(
1
,
UP
);
fprintf
(
stdout
,
"
\033
[2K"
);
}
fflush
(
stdout
);
}
void
showOnScreen
(
Command
*
cmd
)
{
struct
winsize
w
;
if
(
ioctl
(
0
,
TIOCGWINSZ
,
&
w
)
<
0
||
w
.
ws_col
==
0
||
w
.
ws_row
==
0
)
{
fprintf
(
stderr
,
"No stream device
\n
"
);
exit
(
EXIT_FAILURE
);
}
wchar_t
wc
;
int
size
=
0
;
// Print out the command.
char
*
total_string
=
malloc
(
MAX_COMMAND_SIZE
);
memset
(
total_string
,
'\0'
,
MAX_COMMAND_SIZE
);
if
(
strcmp
(
cmd
->
buffer
,
""
)
==
0
)
{
sprintf
(
total_string
,
"%s%s"
,
PROMPT_HEADER
,
cmd
->
command
);
}
else
{
sprintf
(
total_string
,
"%s%s"
,
CONTINUE_PROMPT
,
cmd
->
command
);
}
int
remain_column
=
w
.
ws_col
;
/* size = cmd->commandSize + prompt_size; */
for
(
char
*
str
=
total_string
;
size
<
cmd
->
commandSize
+
prompt_size
;)
{
int
ret
=
mbtowc
(
&
wc
,
str
,
MB_CUR_MAX
);
if
(
ret
<
0
)
break
;
size
+=
ret
;
/* assert(size >= 0); */
int
width
=
wcwidth
(
wc
);
if
(
remain_column
>
width
)
{
printf
(
"%lc"
,
wc
);
remain_column
-=
width
;
}
else
{
if
(
remain_column
==
width
)
{
printf
(
"%lc
\n\r
"
,
wc
);
remain_column
=
w
.
ws_col
;
}
else
{
printf
(
"
\n\r
%lc"
,
wc
);
remain_column
=
w
.
ws_col
-
width
;
}
}
str
=
total_string
+
size
;
}
free
(
total_string
);
/* for (int i = 0; i < size; i++){ */
/* char c = total_string[i]; */
/* if (k % w.ws_col == 0) { */
/* printf("%c\n\r", c); */
/* } */
/* else { */
/* printf("%c", c); */
/* } */
/* k += 1; */
/* } */
// Position the cursor
int
cursor_pos
=
cmd
->
screenOffset
+
prompt_size
;
int
ecmd_pos
=
cmd
->
endOffset
+
prompt_size
;
int
cursor_x
=
cursor_pos
/
w
.
ws_col
;
int
cursor_y
=
cursor_pos
%
w
.
ws_col
;
// int cursor_y = cursor % w.ws_col;
int
command_x
=
ecmd_pos
/
w
.
ws_col
;
int
command_y
=
ecmd_pos
%
w
.
ws_col
;
// int command_y = (command.size() + prompt_size) % w.ws_col;
positionCursor
(
command_y
,
LEFT
);
positionCursor
(
command_x
,
UP
);
positionCursor
(
cursor_x
,
DOWN
);
positionCursor
(
cursor_y
,
RIGHT
);
fflush
(
stdout
);
}
void
cleanup_handler
(
void
*
arg
)
{
tcsetattr
(
0
,
TCSANOW
,
&
oldtio
);
}
void
exitShell
()
{
tcsetattr
(
0
,
TCSANOW
,
&
oldtio
);
exit
(
EXIT_SUCCESS
);
}
src/kit/shell/src/shellEngine.c
浏览文件 @
7d815b24
...
...
@@ -96,7 +96,7 @@ TAOS *shellInit(struct arguments *args) {
exit
(
EXIT_SUCCESS
);
}
#if
def LINUX
#if
ndef WINDOWS
if
(
args
->
dir
[
0
]
!=
0
)
{
source_dir
(
con
,
args
);
taos_close
(
con
);
...
...
src/kit/shell/src/shellImport.c
浏览文件 @
7d815b24
...
...
@@ -90,20 +90,12 @@ static void shellParseDirectory(const char *directoryName, const char *prefix, c
static
void
shellCheckTablesSQLFile
(
const
char
*
directoryName
)
{
char
cmd
[
1024
]
=
{
0
};
sprintf
(
cmd
,
"ls %s/tables.sql"
,
directoryName
);
sprintf
(
shellTablesSQLFile
,
"%s/tables.sql"
,
directoryName
);
FILE
*
fp
=
popen
(
cmd
,
"r"
);
if
(
fp
==
NULL
)
{
fprintf
(
stderr
,
"ERROR: failed to execute:%s, error:%s
\n
"
,
cmd
,
strerror
(
errno
));
exit
(
0
);
struct
stat
fstat
;
if
(
stat
(
shellTablesSQLFile
,
&
fstat
)
<
0
)
{
shellTablesSQLFile
[
0
]
=
0
;
}
while
(
fscanf
(
fp
,
"%s"
,
shellTablesSQLFile
))
{
break
;
}
pclose
(
fp
);
}
static
void
shellMallocSQLFiles
()
...
...
src/os/darwin/inc/os.h
浏览文件 @
7d815b24
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_PLATFORM_DARWIN_H
#define TDENGINE_PLATFORM_DARWIN_H
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TDENGINE_PLATFORM_LINUX_H
#define TDENGINE_PLATFORM_LINUX_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <float.h>
#include <ifaddrs.h>
#include <libgen.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <netdb.h>
#include <pwd.h>
#include <syslog.h>
#include <termios.h>
#include <wordexp.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <pthread.h>
#include <pwd.h>
#include <regex.h>
#include <semaphore.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/statvfs.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <stdint.h>
#include <pthread.h>
#include <stdbool.h>
#include <limits.h>
#include <locale.h>
#include <syslog.h>
#include <termios.h>
#include <unistd.h>
#include <wchar.h>
#include <wordexp.h>
#include <wctype.h>
#include <inttypes.h>
#include <dispatch/dispatch.h>
#define htobe64 htonll
#define taosCloseSocket(x) \
{ \
if (FD_VALID(x)) {
\
if (FD_VALID(x)) { \
close(x); \
x =
-1;
\
x =
FD_INITIALIZER;
\
} \
}
#define taosWriteSocket(fd, buf, len) write(fd, buf, len)
#define taosReadSocket(fd, buf, len) read(fd, buf, len)
...
...
@@ -160,7 +188,7 @@
(__a < __b) ? __a : __b; \
})
#define MILLISECOND_PER_SECOND (1000L)
#define MILLISECOND_PER_SECOND (
(int64_t)
1000L)
#define tsem_t dispatch_semaphore_t
...
...
@@ -197,6 +225,10 @@ bool taosSkipSocketCheck();
bool
taosGetDisk
();
int
fsendfile
(
FILE
*
out_file
,
FILE
*
in_file
,
int64_t
*
offset
,
int32_t
count
);
void
taosSetCoreDump
();
typedef
int
(
*
__compar_fn_t
)(
const
void
*
,
const
void
*
);
// for send function in tsocket.c
...
...
@@ -219,4 +251,8 @@ typedef int(*__compar_fn_t)(const void *, const void *);
#define BUILDIN_CLZ(val) __builtin_clz(val)
#define BUILDIN_CTZ(val) __builtin_ctz(val)
#endif
\ No newline at end of file
#ifdef __cplusplus
}
#endif
#endif
src/os/darwin/src/tdarwin.c
浏览文件 @
7d815b24
...
...
@@ -33,11 +33,11 @@
#include "tsdb.h"
#include "tutil.h"
char
configDir
[
TSDB_FILENAME_LEN
]
=
"
~/TDengine/cfg
"
;
char
tsDirectory
[
TSDB_FILENAME_LEN
]
=
"
~/TDengine/data
"
;
char
dataDir
[
TSDB_FILENAME_LEN
]
=
"
~/TDengine/data
"
;
char
logDir
[
TSDB_FILENAME_LEN
]
=
"~/TDengine
/l
og"
;
char
scriptDir
[
TSDB_FILENAME_LEN
]
=
"
~/TDengine/script
"
;
char
configDir
[
TSDB_FILENAME_LEN
]
=
"
/etc/taos
"
;
char
tsDirectory
[
TSDB_FILENAME_LEN
]
=
"
/var/lib/taos
"
;
char
dataDir
[
TSDB_FILENAME_LEN
]
=
"
/var/lib/taos
"
;
char
logDir
[
TSDB_FILENAME_LEN
]
=
"~/TDengine
L
og"
;
char
scriptDir
[
TSDB_FILENAME_LEN
]
=
"
/etc/taos
"
;
char
osName
[]
=
"Darwin"
;
int64_t
str2int64
(
char
*
str
)
{
...
...
@@ -419,4 +419,43 @@ int32_t __sync_val_load_32(int32_t *ptr) {
void
__sync_val_restore_32
(
int32_t
*
ptr
,
int32_t
newval
)
{
__atomic_store_n
(
ptr
,
newval
,
__ATOMIC_RELEASE
);
}
\ No newline at end of file
}
#define _SEND_FILE_STEP_ 1000
int
fsendfile
(
FILE
*
out_file
,
FILE
*
in_file
,
int64_t
*
offset
,
int32_t
count
)
{
fseek
(
in_file
,
(
int32_t
)(
*
offset
),
0
);
int
writeLen
=
0
;
uint8_t
buffer
[
_SEND_FILE_STEP_
]
=
{
0
};
for
(
int
len
=
0
;
len
<
(
count
-
_SEND_FILE_STEP_
);
len
+=
_SEND_FILE_STEP_
)
{
size_t
rlen
=
fread
(
buffer
,
1
,
_SEND_FILE_STEP_
,
in_file
);
if
(
rlen
<=
0
)
{
return
writeLen
;
}
else
if
(
rlen
<
_SEND_FILE_STEP_
)
{
fwrite
(
buffer
,
1
,
rlen
,
out_file
);
return
(
int
)(
writeLen
+
rlen
);
}
else
{
fwrite
(
buffer
,
1
,
_SEND_FILE_STEP_
,
in_file
);
writeLen
+=
_SEND_FILE_STEP_
;
}
}
int
remain
=
count
-
writeLen
;
if
(
remain
>
0
)
{
size_t
rlen
=
fread
(
buffer
,
1
,
remain
,
in_file
);
if
(
rlen
<=
0
)
{
return
writeLen
;
}
else
{
fwrite
(
buffer
,
1
,
remain
,
out_file
);
writeLen
+=
remain
;
}
}
return
writeLen
;
}
void
taosSetCoreDump
()
{}
\ No newline at end of file
src/rpc/src/tudp.c
浏览文件 @
7d815b24
...
...
@@ -698,7 +698,12 @@ int taosSendPacketViaTcp(uint32_t ip, uint16_t port, char *data, int dataLen, vo
// send a UDP header first to set up the connection
pHead
=
(
STaosHeader
*
)
buffer
;
memcpy
(
pHead
,
data
,
sizeof
(
STaosHeader
));
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wbitfield-constant-conversion"
pHead
->
tcp
=
2
;
#pragma GCC diagnostic pop
msgLen
=
sizeof
(
STaosHeader
);
pHead
->
msgLen
=
(
int32_t
)
htonl
(
msgLen
);
code
=
taosSendUdpData
(
ip
,
port
,
buffer
,
msgLen
,
chandle
);
...
...
src/util/CMakeLists.txt
浏览文件 @
7d815b24
...
...
@@ -68,9 +68,36 @@ ELSEIF (TD_WINDOWS_64)
TARGET_LINK_LIBRARIES
(
tutil iconv regex pthread os winmm IPHLPAPI ws2_32
)
ELSEIF
(
TD_DARWIN_64
)
ADD_DEFINITIONS
(
-DUSE_LIBICONV
)
AUX_SOURCE_DIRECTORY
(
src SRC
)
LIST
(
REMOVE_ITEM SRC ./src/tcrc32c.c
)
LIST
(
REMOVE_ITEM SRC ./src/tdes.c
)
LIST
(
APPEND SRC ./src/ihash.c
)
LIST
(
APPEND SRC ./src/lz4.c
)
LIST
(
APPEND SRC ./src/shash.c
)
LIST
(
APPEND SRC ./src/tbase64.c
)
LIST
(
APPEND SRC ./src/tcache.c
)
LIST
(
APPEND SRC ./src/tcompression.c
)
LIST
(
APPEND SRC ./src/textbuffer.c
)
LIST
(
APPEND SRC ./src/tglobalcfg.c
)
LIST
(
APPEND SRC ./src/thash.c
)
LIST
(
APPEND SRC ./src/thashutil.c
)
LIST
(
APPEND SRC ./src/thistogram.c
)
LIST
(
APPEND SRC ./src/tidpool.c
)
LIST
(
APPEND SRC ./src/tinterpolation.c
)
LIST
(
APPEND SRC ./src/tlog.c
)
LIST
(
APPEND SRC ./src/tlosertree.c
)
LIST
(
APPEND SRC ./src/tmd5.c
)
LIST
(
APPEND SRC ./src/tmem.c
)
LIST
(
APPEND SRC ./src/tmempool.c
)
LIST
(
APPEND SRC ./src/tmodule.c
)
LIST
(
APPEND SRC ./src/tnote.c
)
LIST
(
APPEND SRC ./src/tsched.c
)
LIST
(
APPEND SRC ./src/tskiplist.c
)
LIST
(
APPEND SRC ./src/tsocket.c
)
LIST
(
APPEND SRC ./src/tstrbuild.c
)
LIST
(
APPEND SRC ./src/ttime.c
)
LIST
(
APPEND SRC ./src/ttimer.c
)
LIST
(
APPEND SRC ./src/ttokenizer.c
)
LIST
(
APPEND SRC ./src/ttypes.c
)
LIST
(
APPEND SRC ./src/tutil.c
)
LIST
(
APPEND SRC ./src/version.c
)
ADD_LIBRARY
(
tutil
${
SRC
}
)
TARGET_LINK_LIBRARIES
(
tutil iconv pthread os
)
ENDIF
()
...
...
src/util/src/tnote.c
浏览文件 @
7d815b24
...
...
@@ -231,8 +231,13 @@ void taosNotePrint(taosNoteInfo * pNote, const char * const format, ...)
gettimeofday
(
&
timeSecs
,
NULL
);
curTime
=
timeSecs
.
tv_sec
;
ptm
=
localtime_r
(
&
curTime
,
&
Tm
);
len
=
sprintf
(
buffer
,
"%02d/%02d %02d:%02d:%02d.%06d %lx "
,
ptm
->
tm_mon
+
1
,
ptm
->
tm_mday
,
ptm
->
tm_hour
,
ptm
->
tm_min
,
ptm
->
tm_sec
,
(
int
)
timeSecs
.
tv_usec
,
pthread_self
());
#ifndef LINUX
len
=
sprintf
(
buffer
,
"%02d/%02d %02d:%02d:%02d.%06d 0x%lld "
,
ptm
->
tm_mon
+
1
,
ptm
->
tm_mday
,
ptm
->
tm_hour
,
ptm
->
tm_min
,
ptm
->
tm_sec
,
(
int
)
timeSecs
.
tv_usec
,
taosGetPthreadId
());
#else
len
=
sprintf
(
buffer
,
"%02d/%02d %02d:%02d:%02d.%06d %lx "
,
ptm
->
tm_mon
+
1
,
ptm
->
tm_mday
,
ptm
->
tm_hour
,
ptm
->
tm_min
,
ptm
->
tm_sec
,
(
int
)
timeSecs
.
tv_usec
,
pthread_self
());
#endif
va_start
(
argpointer
,
format
);
len
+=
vsnprintf
(
buffer
+
len
,
MAX_NOTE_LINE_SIZE
-
len
,
format
,
argpointer
);
va_end
(
argpointer
);
...
...
src/util/src/version.c
浏览文件 @
7d815b24
char
version
[
64
]
=
"1.6.5.1"
;
char
compatible_version
[
64
]
=
"1.6.1.0"
;
char
gitinfo
[
128
]
=
"2ea714387009421beb35e7f03b94c6a87d22529a"
;
char
gitinfoOfInternal
[
128
]
=
"950f54ac026bc05bcec5cff356f4964a18d635bd"
;
char
buildinfo
[
512
]
=
"Built by ubuntu at 2019-12-21 11:14"
;
char
gitinfo
[
128
]
=
"751fa0239baa49c3aaa9b49e15f7812b17519800"
;
char
gitinfoOfInternal
[
128
]
=
""
;
char
buildinfo
[
512
]
=
"Built by guanshengliang at 2020-01-08 15:21"
;
void
libtaos_edge_1_6_5_1_Darwin_x64
()
{};
tests/examples/c/CMakeLists.txt
浏览文件 @
7d815b24
PROJECT
(
TDengine
)
IF
(
TD_WINDOWS
)
IF
(
TD_WINDOWS
_64
)
INCLUDE_DIRECTORIES
(
${
TD_ROOT_DIR
}
/deps/pthread
)
ENDIF
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录