mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 15:04:52 +09:00
Use instanceName in researchSync
Remove silly roundabout way to the get the current instance name.
This commit is contained in:
1 parent
f4ca5d92a1
commit
b191f7d831
1 file changed
+1
-26
@@ -22,8 +22,7 @@ class ResearchSync {
|
||||
this.log_folder = './logs'
|
||||
if (!fs.existsSync(this.log_folder))
|
||||
fs.mkdirSync(this.log_folder);
|
||||
this.log_file = path.join(this.log_folder, `${this.config.unique}-research.log`)
|
||||
this.get_node_name_and_move_log()
|
||||
this.log_file = path.join(this.log_folder, `${this.config.instanceName}-research.log`)
|
||||
|
||||
this.research = {}
|
||||
this.prev_research = {}
|
||||
@@ -50,30 +49,6 @@ class ResearchSync {
|
||||
}
|
||||
}
|
||||
|
||||
get_node_name_and_move_log() {
|
||||
const url = `${this.config.masterIP}:${this.config.masterPort}/api/slaves`
|
||||
needle.get(url, {compressed:true}, (err, res, slaves_data) => {
|
||||
if (err)
|
||||
return this.error(err)
|
||||
|
||||
slaves_data = Object.values(slaves_data)
|
||||
let node_data = slaves_data.find(
|
||||
slave_data => slave_data.unique === this.config.unique.toString()
|
||||
)
|
||||
if (node_data === undefined)
|
||||
return this.error('slave was not found')
|
||||
let node_name = node_data.instanceName
|
||||
let log_file = path.join(this.log_folder, `${node_name}-research.log`)
|
||||
if (fs.existsSync(log_file)) {
|
||||
fs.appendFileSync(log_file, fs.readFileSync(this.log_file));
|
||||
fs.unlinkSync(this.log_file)
|
||||
} else {
|
||||
fs.renameSync(this.log_file, log_file)
|
||||
}
|
||||
this.log_file = log_file
|
||||
})
|
||||
}
|
||||
|
||||
initial_request_own_data(callback) {
|
||||
const url = `${this.config.masterIP}:${this.config.masterPort}/api/getSlaveMeta`
|
||||
const data = {
|
||||
|
||||
Reference in new issue
Block a user