Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 503 http status on db connect failure #583

Open
wants to merge 1 commit into
base: dbHealthCheck
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion www/lib/Reply.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public static function ajax($data)

$res = json_encode($data);

//die($res);
return $res;
}

Expand All @@ -19,6 +18,8 @@ public static function ajaxDie($stat, $msg, $data_tr = '')
$data['msg'] = $msg;
$data['data'] = $data_tr;

http_response_code(503);

die(self::ajax($data));
}
}
2 changes: 1 addition & 1 deletion www/lib/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private function load_config() {

private function connect() {
$this->load_config();
$this->dblink = mysqli_connect($this->dbhost, $this->dbuser, $this->dbpassword, $this->dbname) or die(LANG_DIE_COULDNOTCONNECT);
$this->dblink = mysqli_connect($this->dbhost, $this->dbuser, $this->dbpassword, $this->dbname) or Reply::ajaxDie('service-unavailable-error', LANG_DIE_COULDNOTCONNECT);
mysqli_real_query($this->dblink, "set names utf8;");
}
public static function escapeString(&$string) {
Expand Down