<?php
// This is called by cron, and is persistent.
// It takes care of repository init/clone, merge request to db etc.
error_reporting(E_ALL);
ini_set("track_errors", "On");
$now = time();
$_s = microtime(TRUE);
require_once("/etc/rocketgit/config.php");
$INC = dirname(__FILE__) . "/../inc";
require_once($INC . "/init.inc.php");
require_once($INC . "/log.inc.php");
require_once($INC . "/sql.inc.php");
require_once($INC . "/struct.inc.php");
require_once($INC . "/repo.inc.php");
require_once($INC . "/prof.inc.php");
require_once($INC . "/mr.inc.php");
require_once($INC . "/fixes.inc.php");
require_once($INC . "/plan.inc.php");
require_once($INC . "/ver.php");
rg_prof_start("MAIN");
rg_log_set_file($rg_log_dir . "/q.log");
rg_log_set_sid("000000"); // to spread the logs
// locking
rg_lock_or_exit("q.lock");
rg_log("Start (ver=$rocketgit_version)...");
rg_sql_app("rg-q");
$db = rg_sql_open($rg_sql);
if ($db === FALSE) {
rg_log("Cannot connect to database!");
// TODO: inform admin - already by e-mail?
exit(1);
}
$r = rg_sql_struct_update($db, 0);
if ($r !== TRUE)
exit(1);
$r = rg_fixes_update($db);
if ($r !== TRUE)
exit(1);
$original_mtime = filemtime(__FILE__);
// Check our mtime so we can upgrade the software and this script will restart.
while (TRUE) {
clearstatcache();
$mtime = filemtime(__FILE__);
//rg_log("mtime=$mtime, original_mtime=$original_mtime");
if ($mtime != $original_mtime) {
rg_log("File changed. Exiting...");
break;
}
// check machine load - if too big we will delay
$load = rg_load();
if ($load > 10) {
rg_log("\tLoad too big!");
sleep(10);
continue;
}
// TODO: move it as an event and remove this script
rg_mr_queue_process($db);
sleep(1);
}
rg_prof_end("MAIN");
rg_prof_log();
?>
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/rocketgit
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master