mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-12 00:06:09 +01:00
Added docker to service management
This commit is contained in:
@@ -24,7 +24,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
SECRET_KEY = 'xr%j*p!*$0d%(-(e%@-*hyoz4$f%y77coq0u)6pwmjg4)q&19f'
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
DEBUG = True
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
@@ -110,15 +110,15 @@ DATABASES = {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'cyberpanel',
|
||||
'USER': 'cyberpanel',
|
||||
'PASSWORD': 'Bz9gF7Hr7X4RtD',
|
||||
'PASSWORD': 'a9AwLb7zY7ZwCd',
|
||||
'HOST': '127.0.0.1',
|
||||
'PORT':'3307'
|
||||
'PORT':''
|
||||
},
|
||||
'rootdb': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'mysql',
|
||||
'USER': 'root',
|
||||
'PASSWORD': 'sXm5VlRaAsXkDd',
|
||||
'PASSWORD': '3bL8X7wGo0kT3b',
|
||||
'HOST': 'localhost',
|
||||
'PORT': '',
|
||||
},
|
||||
|
||||
@@ -32,7 +32,6 @@ def preDockerRun(function):
|
||||
return render(request, 'dockerManager/install.html', {'status':admin.type, 'conErr':0})
|
||||
|
||||
# Check if docker is running and we are able to connect
|
||||
|
||||
try:
|
||||
client = docker.from_env()
|
||||
client.ping()
|
||||
|
||||
BIN
serverStatus/static/images/docker.png
Normal file
BIN
serverStatus/static/images/docker.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@@ -394,6 +394,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
|
||||
|
||||
function ListInitialDatas(response) {
|
||||
console.log(response.data)
|
||||
|
||||
if (response.data.status.litespeed) {
|
||||
$scope.olsStatus = "Running";
|
||||
@@ -409,8 +410,18 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
$scope.olsStop = false;
|
||||
}
|
||||
|
||||
// Update SQL stats
|
||||
if (response.data.status.docker) {
|
||||
$scope.dockerStatus = "Running";
|
||||
$scope.dockerStart = false;
|
||||
$scope.dockerStop = true;
|
||||
}
|
||||
else {
|
||||
$scope.dockerStatus = "Stopped";
|
||||
$scope.dockerStart = true;
|
||||
$scope.dockerStop = false;
|
||||
}
|
||||
|
||||
// Update SQL stats
|
||||
if (response.data.status.mysql) {
|
||||
$scope.sqlStatus = "Running";
|
||||
$scope.sqlStats = true;
|
||||
@@ -468,7 +479,7 @@ app.controller('servicesManager', function ($scope, $http) {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
getServiceStatus();
|
||||
|
||||
$scope.serviceAction = function (serviceName, action) {
|
||||
|
||||
@@ -123,6 +123,28 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if isDocker %}
|
||||
<div class="col-sm-6 col-md-6">
|
||||
<div class="panel panel-default service-panel">
|
||||
<div class="panel-body">
|
||||
<div class="serviceImg">
|
||||
<img src="{% static 'images/docker.png' %}" alt="Docker" class="img-circle">
|
||||
</div>
|
||||
<div class="serviceDetails">
|
||||
<div class="serviceHeading">
|
||||
<h5><b>Docker</b></h5>
|
||||
<span class="help-block" ng-bind="dockerStatus">Stopped</span>
|
||||
</div>
|
||||
<div class="serviceActionBtn">
|
||||
<button type="button" class="btn btn-success" ng-disabled="btnDisable" ng-show="dockerStart" ng-click="serviceAction('docker','start')" data-toggle="tooltip" title="Start!"><i class="glyph-icon icon-play" aria-hidden="true"></i></button>
|
||||
<button type="button" class="btn btn-warning" ng-disabled="btnDisable" ng-show="dockerStop" ng-click="serviceAction('docker','stop')" data-toggle="tooltip" title="Stop!"><i class="glyph-icon icon-pause" aria-hidden="true"></i></button>
|
||||
<button type="button" class="btn btn-default" ng-disabled="btnDisable" ng-click="serviceAction('docker','restart')" data-toggle="tooltip" title="Restart!"><i class="glyph-icon icon-refresh" aria-hidden="true"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-3 control-label"></label>
|
||||
|
||||
@@ -165,6 +165,12 @@ def services(request):
|
||||
else:
|
||||
data['serverName'] = 'LiteSpeed Ent'
|
||||
|
||||
dockerInstallPath = '/usr/bin/docker'
|
||||
if not os.path.exists(dockerInstallPath):
|
||||
data['isDocker'] = False
|
||||
else:
|
||||
data['isDocker'] = True
|
||||
|
||||
return render(request, 'serverStatus/services.html', data)
|
||||
except KeyError:
|
||||
return redirect(loadLoginPage)
|
||||
@@ -178,6 +184,7 @@ def servicesStatus(request):
|
||||
dnsStatus = []
|
||||
ftpStatus = []
|
||||
mailStatus = []
|
||||
dockerStatus = []
|
||||
|
||||
processlist = subprocess.check_output(['ps', '-A'])
|
||||
|
||||
@@ -202,8 +209,10 @@ def servicesStatus(request):
|
||||
else:
|
||||
lsStatus.append(0)
|
||||
|
||||
# mysql status
|
||||
# Docker status
|
||||
dockerStatus.append(getServiceStats('docker'))
|
||||
|
||||
# mysql status
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
result = s.connect_ex(('127.0.0.1', 3306))
|
||||
|
||||
@@ -241,7 +250,8 @@ def servicesStatus(request):
|
||||
'mysql': sqlStatus[0],
|
||||
'powerdns': dnsStatus[0],
|
||||
'pureftp': ftpStatus[0],
|
||||
'postfix': mailStatus[0]},
|
||||
'postfix': mailStatus[0],
|
||||
'docker': dockerStatus[0]},
|
||||
'memUsage':
|
||||
{'litespeed': lsStatus[1],
|
||||
'mysql': sqlStatus[1],
|
||||
@@ -277,8 +287,7 @@ def servicesAction(request):
|
||||
else:
|
||||
pass
|
||||
|
||||
if service not in ["lsws", "mysql", "pdns", "pure-ftpd"]:
|
||||
|
||||
if service not in ["lsws", "mysql", "pdns", "pure-ftpd", "docker"]:
|
||||
final_dic = {'serviceAction': 0, "error_message": "Invalid Service"}
|
||||
final_json = json.dumps(final_dic)
|
||||
return HttpResponse(final_json)
|
||||
|
||||
Reference in New Issue
Block a user