Provison hanging

This commit is contained in:
CHIEFSOFT\ameye
2025-09-22 17:55:01 -04:00
parent 69b8f0c64e
commit 8faaa2e721
3 changed files with 55 additions and 32 deletions
+5 -26
View File
@@ -10,31 +10,10 @@ class Home extends BaseController
public function index(): string public function index(): string
{ {
$template = array(
'table_open' => "<table class='table table-sm table-striped table-hover table-bordered table-condensed'>",
'thead_open' => '<thead class=\'bg-indigo\'>',
'thead_close' => '</thead>',
'heading_row_start' => '<tr>',
'heading_row_end' => '</tr>',
'heading_cell_start' => '<th>',
'heading_cell_end' => '</th>',
'tbody_open' => '<tbody>',
'tbody_close' => '</tbody>',
'row_start' => '<tr>',
'row_end' => '</tr>',
'cell_start' => '<td>',
'cell_end' => '</td>',
'row_alt_start' => '<tr>',
'row_alt_end' => '</tr>',
'cell_alt_start' => '<td>',
'cell_alt_end' => '</td>',
'table_close' => '</table>'
);
//$this->load->library('table');
// $this->table->set_template($template);
$data['label_env'] = $this->what_env(); $data['label_env'] = $this->what_env();
$data["hanging_list"] = $this->getProvisionList(20); $data["hanging_list"] = $this->getProvisionList(15, 6);
$data["completed_list"] = $this->getProvisionList(15, 7);
$data["starting_list"] = $this->getProvisionList(15, 1);
return view('welcome_message',$data); return view('welcome_message',$data);
} }
@@ -45,8 +24,8 @@ class Home extends BaseController
return $curr_env; return $curr_env;
} }
private function getProvisionList($limit){ private function getProvisionList($limit,$status){
$mysql ="SELECT * FROM members_products ORDER BY id DESC LIMIT $limit"; $mysql ="SELECT * FROM members_products WHERE status = $status ORDER BY id DESC LIMIT $limit";
$query = $this->db->query($mysql); $query = $this->db->query($mysql);
return $query->getResult(); return $query->getResult();
} }
+21 -2
View File
@@ -537,6 +537,25 @@ class Provision extends BaseController
$this->provisionActions($memberID, $provisionUID, "Allocating Provisioning Ports"); $this->provisionActions($memberID, $provisionUID, "Allocating Provisioning Ports");
} }
//Now let us try fix hanging stuffs
$mysql = "SELECT id, member_id, uid, internal_url,product_id,status,provision_port,updated
FROM members_products
WHERE provision_port > 0
AND status = 6
AND added < now() - INTERVAL '5 minutes'
ORDER BY updated ASC LIMIT 1";
$query = $this->db->query($mysql);
$provision_list = $query->getResult();
foreach ($provision_list as $pr) {
$memberID = $pr->member_id;
$productId = $pr->product_id;
$provisionUID = $pr->uid;
$mysql = "UPDATE members_products SET updated=now(), provision_status=0 WHERE uid::TEXT = '" . $provisionUID . "' AND provision_port > 0";
$query = $this->db->query($mysql);
}
//SELECT * FROM members_products WHERE status = 6 AND added < now() - INTERVAL '5 minutes' LIMIT 1
} }
private function allocatePortNumber($productId) private function allocatePortNumber($productId)
@@ -577,7 +596,7 @@ class Provision extends BaseController
private function provisionServer($productId) private function provisionServer($productId)
{ {
$primaryServer =""; $primaryServer = "";
switch ($productId) { switch ($productId) {
case "A000001": case "A000001":
case "A000002": case "A000002":
@@ -611,7 +630,7 @@ class Provision extends BaseController
[A000005_SERVER] [A000005_SERVER]
172.16.4.95 172.16.4.95
*/ */
private function updateToNow($provisionUID):void private function updateToNow($provisionUID): void
{ {
try { try {
$mysql = "UPDATE members_products SET updated=now(), $mysql = "UPDATE members_products SET updated=now(),
+29 -4
View File
@@ -44,7 +44,7 @@
</thead> </thead>
<tbody> <tbody>
<?php <?php
foreach ($hanging_list ?? [] as $pr) { foreach ($starting_list ?? [] as $pr) {
?> ?>
<tr> <tr>
<th scope="row"><?= $pr->id ?></th> <th scope="row"><?= $pr->id ?></th>
@@ -69,6 +69,7 @@
<th scope="col">Default URL</th> <th scope="col">Default URL</th>
<th scope="col">Added</th> <th scope="col">Added</th>
<th scope="col">Prov. Status</th> <th scope="col">Prov. Status</th>
<th scope="col">Action</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -77,9 +78,12 @@
?> ?>
<tr style="text-align: left;"> <tr style="text-align: left;">
<th scope="row"><?= $pr->id ?></th> <th scope="row"><?= $pr->id ?></th>
<td><a href="https://<?=$pr->internal_url ?>" target="_blank"><?= $pr->internal_url ?></a></td> <td><a href="https://<?= $pr->internal_url ?>" target="_blank"><?= $pr->internal_url ?></a>
<br><b>PORT:</b><?=$pr->provision_port ?>
</td>
<td><?= $pr->added ?></td> <td><?= $pr->added ?></td>
<td><?= $pr->status ?></td> <td><?= $pr->status ?></td>
<td><button id="<?= $pr->uid ?>" class="btn btn-info btn-xs" onclick="return restartProvsion('<?= $pr->uid ?>');" >Restart</button></td>
</tr> </tr>
<?php <?php
} }
@@ -102,11 +106,11 @@
</thead> </thead>
<tbody> <tbody>
<?php <?php
foreach ($hanging_list ?? [] as $pr) { foreach ($completed_list ?? [] as $pr) {
?> ?>
<tr> <tr>
<th scope="row"><?= $pr->id ?></th> <th scope="row"><?= $pr->id ?></th>
<td><?= $pr->internal_url ?></td> <td><a href="https://<?= $pr->internal_url ?>" target="_blank"><?= $pr->internal_url ?></a></td>
<td><?= $pr->added ?></td> <td><?= $pr->added ?></td>
<td><?= $pr->status ?></td> <td><?= $pr->status ?></td>
</tr> </tr>
@@ -121,6 +125,27 @@
</div> </div>
<script type="text/javascript">
<!--
function restartProvsion(link_id) {
if (confirm("Are you sure you want to restart this provisioning?")) {
// do something
} else {
return false;
}
$(link_id).prop('disabled', true);
$.ajax({
url: "/home/resend_pending?link_id=" + link_id
}).done(function (data) {
$(link_id).prop('disabled', false);
});
return false;
}
</script>
</body> </body>
</html> </html>