diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2021-02-26 18:09:01 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2021-02-26 18:09:01 +0300 |
commit | c3fa113769dce4bd97ee4e3b193409d97b569534 (patch) | |
tree | e04a698758a66f1064177a686917caea4042882c /example/run-manual.php | |
parent | c8da2c8b3f5ef5c95dc7978a476a4830ca6d7c0e (diff) |
examples: improve examples
Diffstat (limited to 'example/run-manual.php')
-rw-r--r-- | example/run-manual.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/example/run-manual.php b/example/run-manual.php new file mode 100644 index 0000000..5f9c43d --- /dev/null +++ b/example/run-manual.php @@ -0,0 +1,29 @@ +<?php + +require_once 'vendor/autoload.php'; + +// connecting to mysql +$db = new mysqli(); +if (!$db->real_connect('10.211.55.6', 'jobd', 'password', 'jobd')) + die('Failed to connect.'); + +// adding manual task +$target = 'server1'; +$time = time(); +if (!$db->query("INSERT INTO jobs (target, slot, time_created, status) VALUES ('server1', 'normal', $time, 'manual')")) + die($db->error); + +$id = $db->insert_id; + +try { + // connecting to jobd + $client = new jobd\Client(jobd\Client::WORKER_PORT); + + // launching task + $result = $client->runManual($id); + + // printing the result + print_r($result->getData()); +} catch (Exception $e) { + die($e->getMessage()); +} |