mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-25 07:44:33 +03:00
Add CLI cron worker
This commit is contained in:
parent
ff09ea09cc
commit
e4a104f52e
@ -4,6 +4,11 @@ Options -Indexes
|
|||||||
# Follow symbolic links in the directory
|
# Follow symbolic links in the directory
|
||||||
Options +FollowSymLinks
|
Options +FollowSymLinks
|
||||||
|
|
||||||
|
<IfModule mod_negotiation.c>
|
||||||
|
# Forbid apache to guess file extensions
|
||||||
|
Options -MultiViews
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
# Disable mod_security for Apache 1.x
|
# Disable mod_security for Apache 1.x
|
||||||
<IfModule mod_security.c>
|
<IfModule mod_security.c>
|
||||||
SecFilterEngine Off
|
SecFilterEngine Off
|
||||||
@ -51,3 +56,8 @@ Options +FollowSymLinks
|
|||||||
<FilesMatch "\.(yml|po|ini|handlebars|keep)$">
|
<FilesMatch "\.(yml|po|ini|handlebars|keep)$">
|
||||||
Deny from all
|
Deny from all
|
||||||
</FilesMatch>
|
</FilesMatch>
|
||||||
|
|
||||||
|
# Deny access to CLI cron worker from the outside
|
||||||
|
<Files "cron.php">
|
||||||
|
Deny from all
|
||||||
|
</Files>
|
||||||
|
44
src/mibew/cron.php
Normal file
44
src/mibew/cron.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is a part of Mibew Messenger.
|
||||||
|
*
|
||||||
|
* Copyright 2005-2015 the original author or authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Initialize libraries
|
||||||
|
require_once(dirname(__FILE__) . '/libs/init.php');
|
||||||
|
|
||||||
|
use Mibew\Cache\CacheFactory;
|
||||||
|
use Mibew\Maintenance\CronWorker;
|
||||||
|
|
||||||
|
$configs = load_system_configs();
|
||||||
|
|
||||||
|
// Prepare the cache. It is initialized in the same way as in index.php
|
||||||
|
$cache_factory = new CacheFactory($configs['cache']);
|
||||||
|
// For now directory for cache files cannot be changed via the configs file.
|
||||||
|
$cache_factory->setOption('path', MIBEW_FS_ROOT . '/cache/stash');
|
||||||
|
|
||||||
|
// Do the job.
|
||||||
|
$worker = new CronWorker($cache_factory->getCache());
|
||||||
|
$success = $worker->run();
|
||||||
|
|
||||||
|
if ($success) {
|
||||||
|
echo("All cron jobs done\n");
|
||||||
|
} else {
|
||||||
|
echo("Cron job failed. Here are the errors:\n");
|
||||||
|
foreach ($worker->getErrors() as $error) {
|
||||||
|
echo(' ' . $error . "\n");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user