mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2026-01-10 17:42:06 +01:00
feature: add option to switch to master again
This commit is contained in:
@@ -2970,3 +2970,35 @@ class CloudManager:
|
||||
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def CheckMasterNode(self):
|
||||
try:
|
||||
|
||||
command = 'systemctl status mysql'
|
||||
result = ProcessUtilities.outputExecutioner(command)
|
||||
|
||||
if result.find('active (running)') > -1:
|
||||
final_json = json.dumps({'status': 1})
|
||||
else:
|
||||
final_json = json.dumps({'status': 0, 'error_message': 'MySQL on Main node is not running.'})
|
||||
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException as msg:
|
||||
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
def SyncToMaster(self):
|
||||
try:
|
||||
|
||||
command = '/usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/ClusterManager.py --function SyncToMaster --type Master'
|
||||
ProcessUtilities.executioner(command)
|
||||
|
||||
final_json = json.dumps({'status': 1})
|
||||
return HttpResponse(final_json)
|
||||
|
||||
except BaseException as msg:
|
||||
final_dic = {'status': 0, 'fetchStatus': 0, 'error_message': str(msg)}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
@@ -50,8 +50,12 @@ def router(request):
|
||||
return cm.DetachCluster()
|
||||
elif controller == 'DebugCluster':
|
||||
return cm.DebugCluster()
|
||||
elif controller == 'CheckMasterNode':
|
||||
return cm.CheckMasterNode()
|
||||
elif controller == 'UptimeMonitor':
|
||||
return cm.UptimeMonitor()
|
||||
elif controller == 'SyncToMaster':
|
||||
return cm.SyncToMaster()
|
||||
elif controller == 'FetchMasterBootStrapStatus':
|
||||
return cm.FetchMasterBootStrapStatus()
|
||||
elif controller == 'FetchChildBootStrapStatus':
|
||||
|
||||
Reference in New Issue
Block a user