mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-23 22:03:08 +02:00
wip
This commit is contained in:
parent
ccc79eac91
commit
7994aa96e2
1 changed files with 39 additions and 31 deletions
|
@ -1,27 +1,7 @@
|
||||||
import * as elasticsearch from 'elasticsearch';
|
import * as elasticsearch from 'elasticsearch';
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
|
|
||||||
// Init ElasticSearch connection
|
const index = {
|
||||||
const client = config.elasticsearch ? new elasticsearch.Client({
|
|
||||||
host: `${config.elasticsearch.host}:${config.elasticsearch.port}`
|
|
||||||
}) : null;
|
|
||||||
|
|
||||||
if (client) {
|
|
||||||
// Send a HEAD request
|
|
||||||
client.ping({
|
|
||||||
// Ping usually has a 3000ms timeout
|
|
||||||
requestTimeout: 30000
|
|
||||||
}, error => {
|
|
||||||
if (error) {
|
|
||||||
console.error('elasticsearch is down!');
|
|
||||||
} else {
|
|
||||||
console.log('elasticsearch is available!');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
client.indices.create({
|
|
||||||
index: 'misskey',
|
|
||||||
body: {
|
|
||||||
settings: {
|
settings: {
|
||||||
analysis: {
|
analysis: {
|
||||||
analyzer: {
|
analyzer: {
|
||||||
|
@ -49,8 +29,36 @@ if (client) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Init ElasticSearch connection
|
||||||
|
const client = config.elasticsearch ? new elasticsearch.Client({
|
||||||
|
host: `${config.elasticsearch.host}:${config.elasticsearch.port}`
|
||||||
|
}) : null;
|
||||||
|
|
||||||
|
if (client) {
|
||||||
|
// Send a HEAD request
|
||||||
|
client.ping({
|
||||||
|
// Ping usually has a 3000ms timeout
|
||||||
|
requestTimeout: 30000
|
||||||
|
}, error => {
|
||||||
|
if (error) {
|
||||||
|
console.error('elasticsearch is down!');
|
||||||
|
} else {
|
||||||
|
console.log('elasticsearch is available!');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
client.indices.exists({
|
||||||
|
index: 'misskey'
|
||||||
|
}).then(exist => {
|
||||||
|
if (exist) return;
|
||||||
|
|
||||||
|
client.indices.create({
|
||||||
|
index: 'misskey',
|
||||||
|
body: index
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default client;
|
export default client;
|
||||||
|
|
Loading…
Reference in a new issue