Add flag to not require SQL database, update sample env

master
Skylar Ittner 3 years ago
parent eddea2c9a1
commit 9839586576

@ -7,7 +7,13 @@
*/
$SETTINGS = [
// If true, PHP errors and warnings are outputted, screwing up the JSON.
// Makes it easy to debug though!
"debugmode" => true,
// If this is true and the database isn't configured, everything crashes.
// set to false if no endpoints require a database, or if Medoo isn't being used
// to access the database.
"require_database" => false,
"database" => [
"database_type" => "mysql",
"database_name" => "mysql",
@ -16,6 +22,8 @@ $SETTINGS = [
"password" => "",
"charset" => "utf8"
],
// If memcached is available, enable it. Otherwise a non-persistent shim is used,
// which is pointless. See lib/Memcache.lib.php.
"memcached" => [
"enable" => true,
"server" => "127.0.0.1",
@ -26,6 +34,8 @@ $SETTINGS = [
// Include trailing slash
"urlbase" => "/",
// Third party API keys and configs for various endpoints go here
"openweathermap_appid" => "",
"weather_summary_hours" => 8,

@ -43,12 +43,16 @@ if (envhas("timezone")) {
// Initialize database driver
use Medoo\Medoo;
$database;
try {
$database = new Medoo(env("database", []));
} catch (Exception $ex) {
http_response_code(500);
Logger::log("Database error: $ex");
if (env("require_database")) {
http_response_code(500);
Logger::log("Database error: $ex");
exit("Database error.");
}
}
$memcacheconfig = env("memcached", [

Loading…
Cancel
Save