Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vernemq
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
stack
vernemq
Commits
e8b048cd
Commit
e8b048cd
authored
Nov 07, 2018
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix seneca
parent
877a1dc1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
pubhook/config/chavm.json
+1
-1
pubhook/index.js
+2
-2
pubhook/on_publish.js
+17
-8
No files found.
pubhook/config/chavm.json
View file @
e8b048cd
{
"rabbitmq_host"
:
"npn1.kube.nexpie.com"
,
"rabbitmq_port"
:
"3
1
672"
,
"rabbitmq_port"
:
"3
2
672"
,
"rabbitmq_username"
:
"b1ffb9e39865f3cb70cc2ef14920e023"
,
"rabbitmq_password"
:
"c3efbc0c4bdb1747a31cebac20d9b9b8"
}
pubhook/index.js
View file @
e8b048cd
process
.
env
[
"NODE_ENV"
]
=
"development"
;
process
.
env
[
"NODE_CONFIG_DIR"
]
=
__dirname
+
"/config/"
;
//
process.env["NODE_ENV"] = "development";
//
process.env["NODE_CONFIG_DIR"] = __dirname + "/config/";
var
restify
=
require
(
'restify'
);
var
on_publish
=
require
(
'./on_publish'
)({
debug
:
true
});
...
...
pubhook/on_publish.js
View file @
e8b048cd
...
...
@@ -6,7 +6,7 @@ var LRU = require("lru-cache") ,
maxAge
:
1000
*
60
*
5
});
var
client
=
require
(
'seneca'
)()
var
client
_wf
=
require
(
'seneca'
)()
.
use
(
'seneca-amqp-transport'
)
.
client
({
type
:
'amqp'
,
...
...
@@ -15,6 +15,16 @@ var client = require('seneca')()
});
var
client_push
=
require
(
'seneca'
)()
.
use
(
'seneca-amqp-transport'
)
.
client
({
type
:
'amqp'
,
pin
:
'cmd:push'
,
url
:
'amqp://'
+
config
.
get
(
'rabbitmq_username'
)
+
':'
+
config
.
get
(
'rabbitmq_password'
)
+
'@'
+
config
.
get
(
'rabbitmq_host'
)
+
':'
+
config
.
get
(
'rabbitmq_port'
)
});
module
.
exports
=
function
(
options
=
{})
{
return
function
(
req
,
res
,
next
)
{
...
...
@@ -31,19 +41,18 @@ module.exports = function(options={}) {
var
ptext
=
Buffer
.
from
(
data
.
payload
,
'base64'
).
toString
();
if
(
stopic
&&
ptext
)
{
let
msg
;
switch
(
a
[
0
])
{
case
'wf'
:
case
'writefeed'
:
msg
=
[{
let
wf
msg
=
[{
"topic"
:
stopic
,
"payload"
:
ptext
,
"ts"
:
Date
.
now
(),
"cid"
:
data
.
client_id
,
}];
client
.
act
(
'cmd:wf'
,
{
message
:
JSON
.
stringify
(
msg
)
client
_wf
.
act
(
'cmd:wf'
,
{
message
:
JSON
.
stringify
(
wf
msg
)
},
(
err
,
res
)
=>
{
if
(
err
)
{
throw
err
;
...
...
@@ -52,14 +61,14 @@ module.exports = function(options={}) {
break
;
case
'push'
:
msg
=
[{
let
push
msg
=
[{
"topic"
:
stopic
,
"payload"
:
ptext
,
"ts"
:
Date
.
now
(),
"cid"
:
data
.
client_id
,
}];
client
.
act
(
'cmd:push'
,
{
message
:
JSON
.
stringify
(
msg
)
client
_push
.
act
(
'cmd:push'
,
{
message
:
JSON
.
stringify
(
push
msg
)
},
(
err
,
res
)
=>
{
if
(
err
)
{
throw
err
;
...
...
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