Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
node
/
app-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f97c7129
authored
Nov 04, 2024
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
修改redis为测试环境地址
1 parent
45fb0783
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
.env
src/common/adapters/redis-io.adapter.ts
.env
View file @
f97c712
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
DATABASE_URL="mysql://biz_app_admin:JLOVdxXk@192.168.3.222:3306/app_admin?schema=public"
DATABASE_URL="mysql://biz_app_admin:JLOVdxXk@192.168.3.222:3306/app_admin?schema=public"
QIWEI_WEBHOOK='https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=16eaf975-65bc-4a7c-b744-a81f6236acc2'
QIWEI_WEBHOOK='https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=16eaf975-65bc-4a7c-b744-a81f6236acc2'
REDIS_HOST="192.168.3.209:6379"
SOCKET_PORT= 8080
SOCKET_PORT= 8080
APP_PORT= 3000
APP_PORT= 3000
STATIC_PATH = "public"
STATIC_PATH = "public"
...
...
src/common/adapters/redis-io.adapter.ts
View file @
f97c712
import
{
IoAdapter
}
from
'@nestjs/platform-socket.io'
;
import
{
IoAdapter
}
from
'@nestjs/platform-socket.io'
import
{
ConfigService
}
from
'nestjs-config'
;
import
{
ConfigService
}
from
'nestjs-config'
import
{
ServerOptions
}
from
'socket.io'
;
import
{
ServerOptions
}
from
'socket.io'
import
{
createAdapter
}
from
'@socket.io/redis-adapter'
;
import
{
createAdapter
}
from
'@socket.io/redis-adapter'
import
{
createClient
}
from
'redis'
;
import
{
createClient
}
from
'redis'
export
class
RedisIoAdapter
extends
IoAdapter
{
export
class
RedisIoAdapter
extends
IoAdapter
{
private
adapterConstructor
:
ReturnType
<
typeof
createAdapter
>
;
private
adapterConstructor
:
ReturnType
<
typeof
createAdapter
>
async
connectToRedis
():
Promise
<
void
>
{
async
connectToRedis
():
Promise
<
void
>
{
const
pubClient
=
createClient
({
url
:
`redis://
localhost:6379`
});
const
pubClient
=
createClient
({
url
:
`redis://
${
process
.
env
.
REDIS_HOST
}
`
})
const
subClient
=
pubClient
.
duplicate
()
;
const
subClient
=
pubClient
.
duplicate
()
await
Promise
.
all
([
pubClient
.
connect
(),
subClient
.
connect
()])
;
await
Promise
.
all
([
pubClient
.
connect
(),
subClient
.
connect
()])
this
.
adapterConstructor
=
createAdapter
(
pubClient
,
subClient
)
;
this
.
adapterConstructor
=
createAdapter
(
pubClient
,
subClient
)
}
}
createIOServer
(
port
:
number
,
options
?:
ServerOptions
):
any
{
createIOServer
(
port
:
number
,
options
?:
ServerOptions
):
any
{
const
server
=
super
.
createIOServer
(
port
,
options
)
;
const
server
=
super
.
createIOServer
(
port
,
options
)
server
.
adapter
(
this
.
adapterConstructor
)
;
server
.
adapter
(
this
.
adapterConstructor
)
return
server
;
return
server
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment