Example #1
0
            $options[substr($argv[$i], 2)] = $argv[++$i];
            break;
    }
}
// ---- End read arguments
if ($options["cert"] && !is_readable($options["cert"])) {
    outln("SSL certificate not readable: '{$options['cert']}', exiting.");
    die;
}
register_shutdown_function("on_shutdown");
// Write a flag file with the PID and the port
$pid_file = "{$tmp_dir}/pid." . getmypid();
file_put_contents($pid_file, $options["port"]);
try {
    outln("Starting MLLP Server on port " . $options["port"] . " with user '" . $options["username"] . "'");
    if ($options["cert"]) {
        outln("SSL certificate: '{$options['cert']}'");
    }
    $handler = new CMLLPServer($options["url"], $options["username"], $options["password"], $options["port"], $options["cert"], $options["passphrase"]);
    $handler->run();
    quit();
} catch (Exception $e) {
    $message = $e->getMessage();
    if ($message == "Address already in use") {
        outln($message);
        quit();
    }
    $stderr = fopen("php://stderr", "w");
    fwrite($stderr, $message . PHP_EOL);
}
quit();