aboutsummaryrefslogtreecommitdiff
path: root/example/run-manual.php
blob: 5f9c43d2ca32ece9bd1bea9a4664c158fb58a0cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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());
}