Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenchuanwen
my-yaf-project
Commits
c90a2a90
Commit
c90a2a90
authored
Jan 03, 2019
by
chenchuanwen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bridgestart
parent
57371f7f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
12 deletions
+49
-12
Common.php
application/library/Our/Common.php
+14
-1
OrderService.php
application/models/Business/Order/OrderService.php
+1
-0
application.ini
conf/application.ini
+2
-0
redisPublish.php
scripts/crontab/push/redisPublish.php
+10
-9
runRedisPush.php
scripts/crontab/push/runRedisPush.php
+22
-2
No files found.
application/library/Our/Common.php
View file @
c90a2a90
...
@@ -94,7 +94,20 @@ class Common
...
@@ -94,7 +94,20 @@ class Common
}
}
return
false
;
return
false
;
}
}
public
static
function
redisPublish
(
$control
,
$method
,
$params
){
//发布application.redis.redisPublishName
$conf
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'redis.database.params'
);
$redisPublishName
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'redis.redisPublishName'
);
$redis
=
new
Redis
();
$redis
->
connect
(
$conf
[
'host'
],
$conf
[
'port'
]);
if
(
!
empty
(
$conf
[
'password'
])){
$redis
->
auth
(
$conf
[
'password'
]);
}
$message
=
array
(
$control
,
$method
,
$params
);
$message
=
json_encode
(
$message
);
$ret
=
$redis
->
publish
(
$redisPublishName
,
$message
);
return
$ret
;
}
/**
/**
* 获取客户端IP
* 获取客户端IP
*
*
...
...
application/models/Business/Order/OrderService.php
View file @
c90a2a90
...
@@ -1638,6 +1638,7 @@ class OrderServiceModel extends \Business\AbstractModel
...
@@ -1638,6 +1638,7 @@ class OrderServiceModel extends \Business\AbstractModel
}
}
public
function
testPush
(
$msg
){
public
function
testPush
(
$msg
){
echo
$msg
.
'abcde'
;
echo
$msg
.
'abcde'
;
return
true
;
}
}
/**
/**
* 类实例
* 类实例
...
...
conf/application.ini
View file @
c90a2a90
...
@@ -12,6 +12,8 @@ application.dispatcher.catchException = true
...
@@ -12,6 +12,8 @@ application.dispatcher.catchException = true
; Admin模块用于后台管理
; Admin模块用于后台管理
application.modules
=
Index,Api,Admin,Client
application.modules
=
Index,Api,Admin,Client
redis.redisPublishName
=
'redisPublish'
;
[productone : common]
[productone : common]
; 数据库配置
; 数据库配置
resources.database.params.driver
=
"pdo_mysql"
resources.database.params.driver
=
"pdo_mysql"
...
...
scripts/crontab/push/redisPublish.php
View file @
c90a2a90
...
@@ -4,12 +4,13 @@ require APPLICATION_PATH . '/scripts/crontab/baseCli.php';
...
@@ -4,12 +4,13 @@ require APPLICATION_PATH . '/scripts/crontab/baseCli.php';
require
APPLICATION_PATH
.
'/scripts/crontab/common.php'
;
require
APPLICATION_PATH
.
'/scripts/crontab/common.php'
;
error_reporting
(
E_ALL
^
E_NOTICE
);
error_reporting
(
E_ALL
^
E_NOTICE
);
//发布
//发布
$conf
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'redis.database.params'
);
//$conf = \Yaf\Registry::get('config')->get('redis.database.params');
$redis
=
new
Redis
();
//$redis=new Redis();
$redis
->
connect
(
$conf
[
'host'
],
$conf
[
'port'
]);
//$redis->connect($conf['host'], $conf['port']);
if
(
!
empty
(
$conf
[
'password'
])){
//if(!empty($conf['password'])){
$redis
->
auth
(
$conf
[
'password'
]);
// $redis->auth($conf['password']);
}
//}
$message
=
array
(
'abd'
,
'happy New Year'
);
//$message=array('abd','happy New Year');
$message
=
json_encode
(
$message
);
//$message=json_encode($message);
$ret
=
$redis
->
publish
(
'redisPublish'
,
$message
);
//$ret=$redis->publish('redisPublish',$message);
\Our\Common
::
redisPublish
(
'\Business\Order\OrderServiceModel'
,
'testPush'
,
array
(
'happy New Year'
));
scripts/crontab/push/runRedisPush.php
View file @
c90a2a90
...
@@ -43,7 +43,26 @@ class runRedisPush
...
@@ -43,7 +43,26 @@ class runRedisPush
}
}
}
}
public
function
callback
(
$instance
,
$channelName
,
$message
){
public
function
callback
(
$instance
,
$channelName
,
$message
){
echo
json_encode
(
$message
);
try
{
$message
=
json_decode
(
$message
,
true
);
$callInstance
=
$message
[
'className'
]
::
getInstance
(
\Our\DbNameConst
::
masterDBConnectName
);
echo
$message
.
"
\r\n
"
;
if
(
empty
(
$message
[
'params'
])){
$res
=
call_user_func_array
(
array
(
$callInstance
,
$message
[
'method'
]),
array
());
}
else
{
$res
=
call_user_func_array
(
array
(
$callInstance
,
$message
[
'method'
]),
$message
[
'params'
]);
}
$res
=
(
isset
(
$res
)
&&!
empty
(
$res
))
?
$res
:
false
;
if
(
$res
!==
false
){
echo
'success'
.
"
\r\n
"
;
}
else
{
echo
'fail1'
.
"
\r\n
"
;
}
unset
(
$callInstance
);
\Mysql\LinkMySQLModel
::
unsetDbConecet
();
}
catch
(
Exception
$ex
){
echo
$ex
->
getMessage
();
}
// $orderService=\Business\Order\OrderServiceModel::getInstance();
// $orderService=\Business\Order\OrderServiceModel::getInstance();
// $orderService->testPush($message);
// $orderService->testPush($message);
}
}
...
@@ -59,6 +78,7 @@ class runRedisPush
...
@@ -59,6 +78,7 @@ class runRedisPush
{
{
$pid
=
$this
->
daemon
();
$pid
=
$this
->
daemon
();
$conf
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'redis.database.params'
);
$conf
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'redis.database.params'
);
$redisPublishName
=
\Yaf\Registry
::
get
(
'config'
)
->
get
(
'redis.redisPublishName'
);
$redis
=
new
Redis
();
$redis
=
new
Redis
();
$redis
->
connect
(
$conf
[
'host'
],
$conf
[
'port'
]);
$redis
->
connect
(
$conf
[
'host'
],
$conf
[
'port'
]);
if
(
!
empty
(
$conf
[
'password'
])){
if
(
!
empty
(
$conf
[
'password'
])){
...
@@ -66,7 +86,7 @@ class runRedisPush
...
@@ -66,7 +86,7 @@ class runRedisPush
}
}
//ini_set('default_socket_timeout', -1);(所有长连接不超时)
//ini_set('default_socket_timeout', -1);(所有长连接不超时)
$redis
->
setOption
(
Redis
::
OPT_READ_TIMEOUT
,
-
1
);
$redis
->
setOption
(
Redis
::
OPT_READ_TIMEOUT
,
-
1
);
$result
=
$redis
->
subscribe
(
array
(
'redisPublish'
),
array
(
$this
,
'callback'
));
$result
=
$redis
->
subscribe
(
array
(
$redisPublishName
),
array
(
$this
,
'callback'
));
}
}
private
function
reload
(){
private
function
reload
(){
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment