Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
922b8717
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
922b8717
编写于
10月 11, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fighting with ts-node & watchdog
上级
df8a5c6f
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
34 addition
and
15 deletion
+34
-15
example/room-bot.ts
example/room-bot.ts
+3
-3
src/config.ts
src/config.ts
+11
-3
src/puppet-web/browser.ts
src/puppet-web/browser.ts
+1
-1
src/puppet-web/puppet-web.ts
src/puppet-web/puppet-web.ts
+9
-2
src/puppet-web/watchdog.ts
src/puppet-web/watchdog.ts
+10
-6
未找到文件。
example/room-bot.ts
浏览文件 @
922b8717
...
...
@@ -12,10 +12,10 @@
* - BUG2: leave event not right: sometimes can not found member (any more, because they left)
*/
import
{
Wechaty
,
Config
,
Room
Config
,
Contact
,
Room
,
Wechaty
,
log
}
from
'
../
'
...
...
src/config.ts
浏览文件 @
922b8717
...
...
@@ -18,8 +18,8 @@ type ConfigSetting = {
DEFAULT_APIHOST
:
string
DEFAULT_PROFILE
:
string
DEFAULT_TOKEN
:
string
DEFAULT_PROTOCOL
:
string
CMD_CHROMIUM
:
string
DEFAULT_PROTOCOL
:
string
CMD_CHROMIUM
:
string
DEFAULT_PORT
:
number
port
:
number
...
...
@@ -119,9 +119,17 @@ Config.puppetInstance = function(instance?: Puppet): Puppet {
return
Config
.
_puppetInstance
}
type
WatchdogFood
=
{
data
:
any
,
type
?:
'
HEARTBEAT
'
|
'
POISON
'
,
timeout
?:
number
// millisecond
}
// module.exports = Config.default = Config.Config = Config
export
default
Config
export
{
HeadType
Config
,
HeadType
,
PuppetType
,
WatchdogFood
}
src/puppet-web/browser.ts
浏览文件 @
922b8717
...
...
@@ -566,7 +566,7 @@ class Browser extends EventEmitter {
const
filename
=
this
.
sessionFile
return
new
Promise
((
resolve
,
reject
)
=>
{
require
(
'
fs
'
)
.
unlink
(
filename
,
err
=>
{
fs
.
unlink
(
filename
,
err
=>
{
if
(
err
&&
err
.
code
!==
'
ENOENT
'
)
{
log
.
silly
(
'
PuppetWebBrowser
'
,
'
cleanSession() unlink session file %s fail: %s
'
,
filename
,
err
.
message
)
}
...
...
src/puppet-web/puppet-web.ts
浏览文件 @
922b8717
...
...
@@ -17,7 +17,10 @@
// const fs = require('fs')
// const co = require('co')
import
Config
from
'
../config
'
import
{
Config
,
WatchdogFood
}
from
'
../config
'
import
Contact
from
'
../contact
'
// import FriendRequest from '../friend-request'
import
Message
from
'
../message
'
...
...
@@ -85,7 +88,11 @@ class PuppetWeb extends Puppet {
await
this
.
initBridge
()
log
.
verbose
(
'
PuppetWeb
'
,
'
initBridge() done
'
)
this
.
emit
(
'
watchdog
'
,
{
data
:
'
inited
'
})
const
food
:
WatchdogFood
=
{
data
:
'
inited
'
,
timeout
:
120000
// 2 mins for first login
}
this
.
emit
(
'
watchdog
'
,
food
)
// return this
// }).catch(e => { // Reject
...
...
src/puppet-web/watchdog.ts
浏览文件 @
922b8717
...
...
@@ -17,6 +17,7 @@
import
log
from
'
../brolog-env
'
import
Event
from
'
./event
'
import
{
WatchdogFood
}
from
'
../config
'
/* tslint:disable:variable-name */
const
Watchdog
=
{
...
...
@@ -24,21 +25,24 @@ const Watchdog = {
}
// feed me in time(after 1st feed), or I'll restart system
function
onFeed
({
data
=
''
,
type
=
'
HEARTBEAT
'
,
timeout
=
60000
// 60s default. can be override in options but be careful about the number zero(0)
}
=
{})
{
function
onFeed
(
food
:
WatchdogFood
)
{
// change to tape instead of tap
// type = type || 'HEARTBEAT' // BUG compatible with issue: node-tap strange behaviour cause CircleCI & Travis-CI keep failing #11
// timeout = timeout || 60000 // BUG compatible with issue: node-tap strange behaviour cause CircleCI & Travis-CI keep failing #11
if
(
!
food
.
type
)
{
food
.
type
=
'
HEARTBEAT
'
}
if
(
!
food
.
timeout
)
{
food
.
timeout
=
60000
// 60s default. can be override in options but be careful about the number zero(0)
}
if
(
!
this
)
{
throw
new
Error
(
'
onFeed() must has `this` of instanceof PuppetWeb
'
)
}
const
feed
=
`
${
type
}
:[
${
data
}
]`
const
feed
=
`
${
food
.
type
}
:[
${
food
.
data
}
]`
log
.
silly
(
'
PuppetWebWatchdog
'
,
'
onFeed: %d, %s
'
,
timeout
,
feed
)
if
(
this
.
currentState
()
===
'
killing
'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录