Beispiel #1
0
<?
function mcp_process($fifo) {
  $todo=trim(fgets($fifo));
  $todo=explode(" ", $todo);

  switch($todo[0]) {
    case "restart":
      call_hooks("mcp_restart");
      break;
    case "compile":
      compile($todo[1]);
      break;
    default:
      print "didn't understand ".implode(" ", $todo)."\n";
  }
  return 1;
}

umask(0);
posix_mkfifo($fifo_path, 0666);
$fifo=fopen($fifo_path, "r+");

mcp_register_stream(MCP_READ, $fifo, "mcp_process");
Beispiel #2
0
function renderd_restart() {
  global $apache2_reload_cmd;
  global $root_path;
  global $renderd_start_time;
  global $renderd_cmd;
  global $renderd_proc;
  global $renderd_pipes;
  global $renderd_current;

  renderd_gen_conf();
  renderd_stop();

  chdir($root_path);
  if(!$apache2_reload_cmd)
    $apache2_reload_cmd="sudo /etc/init.d/apache2 reload";
  system($apache2_reload_cmd);

  $renderd_start_time=time();

  if(!$renderd_cmd)
    $renderd_cmd="renderd";

  $descriptors=array(
    0=>array("pipe", "r"),
    1=>array("pipe", "w"),
    2=>array("pipe", "w"),
  );
  $renderd_pipes=array();
  $renderd_proc=
    proc_open("$renderd_cmd -f 2>&1", $descriptors, $renderd_pipes);

  mcp_register_stream(MCP_READ, $renderd_pipes[1], "renderd_read");

  global $renderd_current;
}
Beispiel #3
0
function osm_update_start() {
  global $db_central;
  global $root_path;
  global $osm_update_proc;
  global $osm_update_last_start;
  $working_dir="$root_path/data/updates";

  // make sure the start of two update commands are at least 30 seconds apart
  if($osm_update_last_start+30>time())
    return;

  // it's disabled
  if($osm_update_proc==1)
    return;

  debug(osm_update_status(), "osm_update");

  // it's disabled
  if($osm_update_proc==1)
    return;

  if(!file_exists("$working_dir/state.txt")) {
    debug("ERROR: state_file does not exist. Please create the working directory data/updates/. See http://wiki.openstreetmap.org/wiki/Minutely_Mapnik for details.", "osm_update");

    // disable
    $osm_update_proc=1;
    return;
  }

  $descriptors=array(
    0=>array("pipe", "r"),
    1=>array("pipe", "w"),
    2=>array("pipe", "w"));

  $command="osmosis --read-replication-interval workingDirectory=$working_dir --simplify-change --write-pgsimp-change database={$db_central['name']} password={$db_central['passwd']}";

  debug("osm_update", "starting osmosis ".Date("r"));
  $osm_update_proc=proc_open($command, $descriptors, $pipes, null, array("JAVACMD_OPTIONS"=>"-Xmx512M"));

  mcp_register_stream(MCP_READ, $pipes[1], "osm_update_read_stdout");
  mcp_register_stream(MCP_READ, $pipes[2], "osm_update_read_stderr");
//  if($stdin)
//    fwrite($pipes[0], $stdin);

  fclose($pipes[0]);
}