Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 37 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {writeFileSync} from 'fs' |
||
2 | import OS from '../client/OS' |
||
3 | import nginxElasticsearchConf from '../templates/nginx/elasticsearch' |
||
4 | import {getConfig, jaleNginxAppsPath} from '../utils/jale' |
||
5 | import Nginx from './nginx' |
||
6 | import Service from './service' |
||
7 | |||
8 | class Elasticsearch extends Service { |
||
9 | requireRoot = false |
||
10 | service = 'elasticsearch' |
||
11 | |||
12 | |||
13 | configPath = `${OS.getInstance().usrLocalDir}/etc/elasticsearch/elasticsearch.yml` |
||
14 | dataPath = 'path.data' |
||
15 | dataRootPath = `${OS.getInstance().usrLocalDir}/var` |
||
16 | nginxConfigPath = `${jaleNginxAppsPath}/elasticsearch.conf` |
||
17 | |||
18 | install = async (): Promise<boolean> => { |
||
19 | await OS.getInstance().packageManager.install('homebrew/cask-versions/adoptopenjdk8', true) |
||
20 | await OS.getInstance().packageManager.install('libyaml', false) |
||
21 | await OS.getInstance().packageManager.install(this.service, false) |
||
22 | |||
23 | return true |
||
24 | } |
||
25 | |||
26 | configure = async (): Promise<boolean> => { |
||
27 | const config = await getConfig() |
||
28 | await writeFileSync(this.nginxConfigPath, nginxElasticsearchConf(config.tld)) |
||
29 | await (new Nginx).restart() |
||
30 | |||
31 | return true |
||
32 | } |
||
33 | |||
34 | } |
||
35 | |||
36 | export default Elasticsearch |
||
37 |