试验性功能:内嵌redis启动。
This commit is contained in:
parent
c0f32fb378
commit
f046bb4a91
|
|
@ -81,6 +81,13 @@
|
|||
</build>
|
||||
|
||||
<dependencies>
|
||||
<!--内嵌redis,生产环境请勿使用!!!-->
|
||||
<dependency>
|
||||
<groupId>com.github.tonivade</groupId>
|
||||
<artifactId>claudb</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
package org.jetlinks.community.standalone.configuration;
|
||||
|
||||
import com.github.tonivade.claudb.ClauDB;
|
||||
import com.github.tonivade.claudb.DBConfig;
|
||||
import com.github.tonivade.resp.RespServer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.event.ApplicationPreparedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class EmbeddedRedisConfiguration implements ApplicationListener<ApplicationPreparedEvent>, Ordered {
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationPreparedEvent event) {
|
||||
Environment environment = event.getApplicationContext().getEnvironment();
|
||||
if (!environment.getProperty("spring.redis.embedded.enabled", Boolean.class, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String dataPath = environment.getProperty("spring.redis.embedded.data-path", "./data/redis");
|
||||
new File(dataPath).mkdirs();
|
||||
DBConfig config = new DBConfig();
|
||||
config.setPersistenceActive(true);
|
||||
config.setAofFile(dataPath.concat("/jetlinks.aof"));
|
||||
config.setRdbFile(dataPath.concat("/jetlinks.rdb"));
|
||||
|
||||
RespServer server = ClauDB.builder()
|
||||
.port(environment.getProperty("spring.redis.embedded.port", Integer.class, 6379))
|
||||
.host(environment.getProperty("spring.redis.embedded.host", "0.0.0.0"))
|
||||
.config(config)
|
||||
.build();
|
||||
server.start();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return Ordered.HIGHEST_PRECEDENCE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
org.springframework.context.ApplicationListener=\
|
||||
org.jetlinks.community.standalone.configuration.EmbeddedRedisConfiguration
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
spring:
|
||||
redis:
|
||||
host: redis
|
||||
port: 6379
|
||||
r2dbc:
|
||||
url: r2dbc:postgresql://postgres:5432/jetlinks
|
||||
username: postgres
|
||||
password: jetlinks
|
||||
management:
|
||||
metrics:
|
||||
export:
|
||||
elastic:
|
||||
host: http://elasticsearch:9200
|
||||
index: jetlinks-metrics
|
||||
elasticsearch:
|
||||
client:
|
||||
host: elasticsearch
|
||||
port: 9200
|
||||
hsweb:
|
||||
file:
|
||||
upload:
|
||||
static-file-path: ./static/upload
|
||||
static-location: http://127.0.0.1:8844/upload
|
||||
cache:
|
||||
type: redis
|
||||
redis:
|
||||
local-cache-type: guava
|
||||
logging:
|
||||
level:
|
||||
org.jetlinks: info
|
||||
rule.engine: info
|
||||
org.hswebframework: warn
|
||||
org.springframework.transaction: warn
|
||||
org.springframework.data.r2dbc.connectionfactory: warn
|
||||
io.micrometer: warn
|
||||
org.hswebframework.expands: warn
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
spring:
|
||||
resources:
|
||||
static-locations: file:./index/, file:./static/,/,classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/, classpath:/public/
|
||||
redis:
|
||||
embedded:
|
||||
enabled: true # 使用内置的redis,不建议在生产环境中使用.
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
data-path: ./data/redis
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: 1024
|
||||
timeout: 20s
|
||||
r2dbc:
|
||||
url: r2dbc:h2:file:///./data/h2db/jetlinks
|
||||
username: sa
|
||||
password:
|
||||
pool:
|
||||
max-size: 32
|
||||
easyorm:
|
||||
default-schema: PUBLIC # 数据库默认的schema
|
||||
dialect: h2 #数据库方言
|
||||
elasticsearch:
|
||||
embedded:
|
||||
enabled: true # 为true时使用内嵌的elasticsearch,不建议在生产环境中使用
|
||||
data-path: ./data/elasticsearch
|
||||
port: 9200
|
||||
host: 0.0.0.0
|
||||
client:
|
||||
host: localhost
|
||||
port: 9200
|
||||
max-conn-total: 128
|
||||
connect-timeout: 5000
|
||||
socket-timeout: 5000
|
||||
connection-request-timeout: 8000
|
||||
index:
|
||||
default-strategy: time-by-month #默认es的索引按月进行分表, direct则为直接操作索引.
|
||||
settings:
|
||||
number-of-shards: 1 # es 分片数量
|
||||
number-of-replicas: 0 # 副本数量
|
||||
device:
|
||||
message:
|
||||
writer:
|
||||
time-series:
|
||||
enabled: true #写出设备消息数据到elasticsearch
|
||||
logging:
|
||||
level:
|
||||
com.github.tonivade: error
|
||||
|
|
@ -106,6 +106,7 @@ logging:
|
|||
org.jetlinks.gateway: debug
|
||||
org.springframework: warn
|
||||
org.elasticsearch: error
|
||||
config: classpath:logback-spring.xml
|
||||
vertx:
|
||||
max-event-loop-execute-time-unit: seconds
|
||||
max-event-loop-execute-time: 30
|
||||
|
|
|
|||
10
pom.xml
10
pom.xml
|
|
@ -347,6 +347,16 @@
|
|||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
|
||||
<!-- <repository>-->
|
||||
<!-- <id>sonatype-snapshots</id>-->
|
||||
<!-- <name>Nexus Snapshot Repository</name>-->
|
||||
<!-- <url>https://oss.sonatype.org/content/repositories/snapshots</url>-->
|
||||
<!-- <snapshots>-->
|
||||
<!-- <enabled>true</enabled>-->
|
||||
<!-- <updatePolicy>daily</updatePolicy>-->
|
||||
<!-- </snapshots>-->
|
||||
<!-- </repository>-->
|
||||
|
||||
</repositories>
|
||||
|
||||
<distributionManagement>
|
||||
|
|
|
|||
Loading…
Reference in New Issue