mirror of
https://github.com/mempool/mempool.git
synced 2025-01-07 22:19:21 +01:00
30 lines
599 B
TypeScript
30 lines
599 B
TypeScript
|
import * as fs from 'fs';
|
||
|
import * as os from 'os';
|
||
|
|
||
|
class BackendInfo {
|
||
|
gitCommitHash = '';
|
||
|
hostname = '';
|
||
|
|
||
|
constructor() {
|
||
|
this.setLatestCommitHash();
|
||
|
this.hostname = os.hostname();
|
||
|
}
|
||
|
|
||
|
public getBackendInfo() {
|
||
|
return {
|
||
|
'hostname': this.hostname,
|
||
|
'git-commit': this.gitCommitHash,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
private setLatestCommitHash(): void {
|
||
|
try {
|
||
|
this.gitCommitHash = fs.readFileSync('../.git/refs/heads/master').toString().trim();
|
||
|
} catch (e) {
|
||
|
console.log('Could not load git commit info, skipping.');
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default new BackendInfo();
|