Skip to content

Commit eedc64a

Browse files
Merge pull request #26 from CppComet/alfa
3.26
2 parents 2c19f91 + 9973c89 commit eedc64a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+6915
-2876
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/CMakeFiles/

CHANGELOG.md

+22-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,27 @@ FEATURES:
55
IMPROVEMENTS:
66
BUG FIXES:
77

8+
## v3.26
9+
10+
BUG FIXES:
11+
12+
* bug fix to query `select * from pipes where name in ("web_test");`
13+
* Command systemctl stop comet.service does not work on Ubuntu 16 ( #17 )
14+
15+
IMPROVEMENTS:
16+
17+
* Added parameter `send_user_online_events` to `main`
18+
* Added parameter `send_user_offline_events` to `main`
19+
* Added parameter `save_users_last_online_time` to `main`
20+
21+
* Added section `cluster`
22+
* Added section `cometqlproxy`
23+
* Added clustering mechanism #15
24+
* Added pidfile option in section `main`.`pidfile`
25+
26+
* Added queryes like `set paramName paramValue`
27+
* Added queryes like `set sectionName paramName paramValue`
28+
829
## v3.25
930

1031
IMPROVEMENTS:
@@ -68,4 +89,4 @@ FEATURES:
6889
* Added server version to ws answer
6990
* Js Api version 3.26
7091
* Removed message `setState` from console log in Js Api
71-
* Fixed bug when Js api in offline
92+
* Fixed bug when Js api in offline

comet-service.sh

+17-46
Original file line numberDiff line numberDiff line change
@@ -10,64 +10,35 @@
1010
### END INIT INFO
1111

1212
PATH=/sbin:/usr/sbin:/bin:/usr/bin
13-
RUNDIR=/root/comet/
14-
CONFIG=/root/comet/comet.conf
13+
RUNDIR=/etc/comet-server/
1514
EXTRAOPTS=
16-
PIDFILE=
17-
15+
PIDFILE=/var/run/cppcomet.pid
1816

1917
echo "CppComet"
20-
18+
2119
cd ${RUNDIR}
22-
20+
2321
case "$1" in
24-
start)
25-
startCount=`ps auxH | grep "comet-start.sh" | wc -l`
26-
if [ $startCount -ne 2 ]
22+
start)
23+
if [test -f "$PIDFILE"]
2724
then
28-
count=`ps auxH | grep "cpp_comet" | wc -l`
29-
if [ $count -le 40 ]
30-
then
31-
echo "Starting CppComet"
32-
nohup ./comet-start.sh > cpp_comet.log &
33-
else
34-
echo "CppComet already run"
35-
fi
36-
else
3725
echo "CppComet already run"
26+
else
27+
echo "Starting CppComet"
28+
nohup ./comet-start.sh > /var/log/cpp_comet.log &
3829
fi
3930
;;
4031
stop)
4132
echo "Stopping CppComet"
42-
ps aux | grep -E "comet-start.sh" | grep -o -E "root +([0-9]+)" | grep -o -E "[0-9]+" | xargs kill
43-
ps auxH | grep "comet-start.sh" | grep -o -E "root +([0-9]+)" | grep -o -E "[0-9]+" | xargs kill
44-
45-
46-
ps aux | grep -E "cpp_comet" | grep -o -E "root +([0-9]+)" | grep -o -E "[0-9]+" | xargs kill
47-
ps auxH | grep "cpp_comet" | grep -o -E "root +([0-9]+)" | grep -o -E "[0-9]+" | xargs kill
48-
33+
kill `cat $PIDFILE`
34+
`rm -rf $PIDFILE`
4935
;;
5036
*)
5137
echo "Stopping CppComet"
52-
ps aux | grep -E "comet-start.sh" | grep -o -E "root +([0-9]+)" | grep -o -E "[0-9]+" | xargs kill
53-
ps auxH | grep "comet-start.sh" | grep -o -E "root +([0-9]+)" | grep -o -E "[0-9]+" | xargs kill
54-
55-
ps aux | grep -E "cpp_comet" | grep -o -E "root +([0-9]+)" | grep -o -E "[0-9]+" | xargs kill
56-
ps auxH | grep "cpp_comet" | grep -o -E "root +([0-9]+)" | grep -o -E "[0-9]+" | xargs kill
57-
58-
startCount=`ps auxH | grep "comet-start.sh" | wc -l`
59-
if [ $startCount -ne 2 ]
60-
then
61-
count=`ps auxH | grep "cpp_comet" | wc -l`
62-
if [ $count -le 40 ]
63-
then
64-
echo "Starting CppComet"
65-
nohup ./comet-start.sh > cpp_comet.log &
66-
else
67-
echo "CppComet already run"
68-
fi
69-
else
70-
echo "CppComet already run"
71-
fi
72-
;;
38+
kill `cat $PIDFILE`
39+
`rm -rf $PIDFILE`
40+
41+
echo "Starting CppComet"
42+
nohup ./cpp_comet > /var/log/cpp_comet.log &
43+
;;
7344
esac

comet-start.sh

-1
This file was deleted.

comet.ini

+30-10
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99
; Password for accessing comet server api
1010
password = 0000000000000000000000000000000000000000000000000000000000000000
1111

12+
send_user_online_events = true
13+
send_user_offline_events = true
14+
15+
; Whether it is necessary to save in a bd time when the user was last time online or it is not necessary
16+
; If you do not save that load for a bd less
17+
save_users_last_online_time = true
18+
19+
20+
pidfile = /var/run/cppcomet.pid ; address for pid file (do not change if necessary)
21+
1222
[db]
1323
host = localhost
1424
user = root
@@ -25,6 +35,10 @@ uptimeTestInterval = 600 ; The interval for checking the uptime of the connectio
2535
maxUptime = 0 ; The maximum value of uptime after which the connection is disconnected.
2636
host = * ; comma separated hosts from which allows receiving connections, or asterisk symbol for allowing connections from any host
2737

38+
; The parameters of the cluster (without spaces or anything else between the parameters, are case sensitive)
39+
;cluster = []Server=127.0.0.1,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3311
40+
;cluster = []Server=127.0.0.1,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3321
41+
2842
[cometql]
2943
ip = 0.0.0.0
3044
thread_num = 3 ; number of threads for receive message from cometql
@@ -37,20 +51,26 @@ maxUptime = 0
3751
allow = true ; https://comet-server.com/wiki/doku.php/en:comet:ini-file#section_statistics
3852

3953

40-
[cluster]
41-
42-
; Параметры кластера
43-
cometql = []host1.ru:3300@password
44-
cometql = []host2.ru:3300@password
45-
cometql = []host3.ru:3300@password
46-
cometql = []host4.ru:3300@password
47-
cometql = []host5.ru:3300@password
48-
54+
[cometqlproxy]
55+
; Clustering Functions
56+
;
57+
ip = 0.0.0.0
58+
thread_num = 3 ; number of threads for receive message from cometql
59+
statistics = 10
60+
port = 3301
61+
uptimeTestInterval = 600
62+
maxUptime = 0
63+
64+
; The parameters of the cluster (without spaces or anything else between the parameters, are case sensitive)
65+
;cluster = []Server=127.0.0.1,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3301
66+
;cluster = []Server=127.0.0.1,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3311
67+
;cluster = []Server=127.0.0.1,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3321
68+
4969
[content-type]
5070
js = application/javascript
5171

5272
[log]
53-
level = 200; Logging level (600 output all, 200 errors only)
73+
level = 500; Logging level (600 output all, 200 errors only)
5474

5575
; Logging levels for individual subsystems
5676
; Change only if debugging is necessary

coverage/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ execute_process( COMMAND bison -d --verbose --debug ../src/CometQL.y -o ../src/C
9292
execute_process( COMMAND yacc -d --verbose --debug ../src/CometQL.y -o ../src/CometQL.cc)
9393
execute_process( COMMAND cc -c ../src/lex.yy.c -o ../src/lex.yy.o)
9494

95+
add_definitions(-DUSE_COVERAGE=1)
9596

9697
# Установка переменной со списком исходников для исполняемого файла
9798
set(SOURCE_EXE
@@ -133,4 +134,3 @@ target_link_libraries (cpp_comet_coverage ${CMAKE_THREAD_LIBS_INIT} ${MYSQL_LIB
133134

134135
#cmake ./ && make
135136

136-

coverage/cometN1.ini

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
; CppComet https://github.com/CppComet/comet-server
2+
;
3+
; docs for this file ./docs/comet.ini.md
4+
; docs for CppComet https://comet-server.com/wiki/doku.php
5+
;
6+
7+
[main]
8+
9+
; Password for accessing comet server api
10+
password = 0000000000000000000000000000000000000000000000000000000000000000
11+
12+
send_user_online_events = true
13+
send_user_offline_events = true
14+
15+
; надо ли сохранять в бд время когда пользователь был последний раз онлайн или не надо
16+
; Если не сохранять то нагрузка на бд меньше
17+
save_users_last_online_time = true
18+
19+
pidfile = /var/run/cppcomet.pid ; адрес для pid файла (не менять без нужды)
20+
21+
[db]
22+
host = test.comet.su
23+
user = root
24+
password = OeN1UYBrpvZo
25+
name = comet_db
26+
port = 3305
27+
28+
[ws]
29+
ip = 0.0.0.0
30+
thread_num = 1 ; number of threads for receive message from websockets
31+
statistics = 10 ;Interval between load measurements (0 = not measured)
32+
port = 8087 ; When connecting to js api, do not forget to specify the port in the node parameter
33+
uptimeTestInterval = 60 ; The interval for checking the uptime of the connections (it also corrects the value of the online user count for one)
34+
maxUptime = 59 ; The maximum value of uptime after which the connection is disconnected.
35+
host = * ; comma separated hosts from which allows receiving connections, or asterisk symbol for allowing connections from any host
36+
37+
cluster = []Server=test.comet.su,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3310
38+
cluster = []Server=test.comet.su,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3320
39+
40+
[cometql]
41+
ip = 0.0.0.0
42+
thread_num = 1 ; number of threads for receive message from cometql
43+
statistics = 10
44+
port = 3300
45+
uptimeTestInterval = 60
46+
maxUptime = 59
47+
48+
[statistics]
49+
allow = true ; https://comet-server.com/wiki/doku.php/en:comet:ini-file#section_statistics
50+
to_log = true
51+
52+
[cometqlproxy]
53+
; Функции кластеризации
54+
;
55+
ip = 0.0.0.0
56+
thread_num = 1 ; number of threads for receive message from cometql
57+
statistics = 10
58+
port = 3301
59+
uptimeTestInterval = 60
60+
maxUptime = 59
61+
62+
; Параметры кластера (без пробелов и прочего между параметрами, регистрозависимо)
63+
cluster = []Server=test.comet.su,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3300
64+
cluster = []Server=test.comet.su,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3300
65+
cluster = []Server=test.comet.su,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3300
66+
cluster = []Server=test.comet.su,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3310
67+
cluster = []Server=test.comet.su,Database=CometQL_v1,Uid=root,Pwd=0000000000000000000000000000000000000000000000000000000000000000,Port=3320
68+
69+
[content-type]
70+
js = application/javascript
71+
72+
[log]
73+
level = 500; Logging level (600 output all, 200 errors only)
74+
75+
; Logging levels for individual subsystems
76+
; Change only if debugging is necessary
77+
Any = 500
78+
TagLoger = 500
79+
appConf = 500
80+
pipeCommands = 500
81+
statistics = 500
82+
removeOldConnections = 500
83+
MySqlServer = 500
84+
UserIndex = 500
85+
UserItem = 500
86+
ClientServer = 500
87+
ServerServer = 500
88+
SimpleRedisClient = 500
89+
tcpServer = 500
90+
CometQLCluster = 500
91+
devManager = 500
92+
dbLink = 500

coverage/coverage.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#!/bin/bash
22

3-
3+
rm -rf cov
44
mkdir cov
55
cd cov
66

77
# Определение coverage
88
# find ./ -type f -iname '*.gcno' | grep "main" | sed -e 's/main.cpp/*/g'
99
files=`find ../ -type f -iname '*.gcno' | grep "main" | sed -e 's/main.cpp/*/g'`
1010

11-
print "nnn - $files"
1211

1312
lcov --directory .. --capture --output-file cov.tmp1
1413
gcov -b $files
@@ -19,11 +18,9 @@ gcov -b $files
1918
mkdir cov
2019

2120
nstart1=`cat cov.tmp1 | grep -n "\.cc" | grep -E -o "^[0-9]+"`
22-
print "nnn - $nstart1"
2321
cat cov.tmp1 | sed -e "$nstart1,/end_of_record/d" > cov.tmp2
2422

2523
nstart2=`cat cov.tmp2 | grep -n "\.y" | grep -E -o "^[0-9]+"`
26-
print "nnn - $nstart2"
2724
cat cov.tmp2 | sed -e "$nstart2,/end_of_record/d" > cov.info
2825

2926
genhtml -o ./cov cov.info
@@ -32,4 +29,3 @@ genhtml -o ./cov cov.info
3229

3330

3431

35-

coverage/readme.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11

22
## Calculate coverage
33

4-
Scripts for calculate coverage in tests
4+
Scripts for calculate coverage in tests
5+
6+
7+
```apt-get install lcov```
8+
9+
10+
```sh ./run.sh```
11+
12+
13+
```sh ./coverage.sh```
14+
15+

coverage/run.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
# Запуск с coverage
4+
cmake .
5+
make
6+
7+
# Запуск под valgrind
8+
./cpp_comet_coverage --conf ./cometN1.ini
9+

0 commit comments

Comments
 (0)