Restart Services

Use Restart Service API to restart particular service on VPS of your server.

HTTP Request

https://hostname:4083/index.php?act=services&svs=vpsid

Parameters

NameTypeValueDescriptionRequired
actGETservicesThe action which will list services that are running inside the vps.Yes
svsPOSTvpsidThe vpsid whose services have to be restarted. Will be sent via URL.Yes
vidPOSTvpsidThe vpsid whose services have to be restarted. Will be sent as a POST Parameter.Yes
restart_xPOST1/0If set then the restart method will start the process.Yes
sel_servPOSTsel_servName of the service that needs to be restarted.Yes

Sample Code

PHP

<?php
    require_once('/usr/local/virtualizor/sdk/enduser.php');

    $key =  'your_api_key';
    $pass = 'you_api_pass';
    $ip = 'your_server_ip';

    $admin = new Virtualizor_Enduser_API($ip, $key, $pass);

    $vid = 3615;

    $post['restart_x'] = 1;
    $post['sel_serv'][] = 'sshd';

    $output = $admin->services($post,$vid);

    print_r(json_encode($output));
?>

Curl

curl -k -X POST -d "restart_x=1&sel_serv=mingetty" -L
"https://hostname:4083/index.php?act=services& 
svs=3615&api=json&apikey=your_api_key& 
apipass=your_api_pass"

Output

{
    "uid": "372",
    "act": "services",
    "timezone": 1,
    "timenow": "October 11, 2016, 3:50 am",
    "vpsid": 3615,
    "username": "test@test.com",
    "user_type": "2",
    "preferences": {
        "fname": "test",
        "lname": "test",
        "language": "english",
        "theme": "default",
        "timezone": 1,
        "logo": ""
    },
    "url": "index.php?",
    "rdns": {
        "pdnsid": "12"
    },
    "pdns": {
        "pdnsid": "12"
    },
    "support_link": "http://softaculous.com",
    "title": "Services",
    "services": {
        "0": "init",
        "1": "kthreadd/105",
        "2": "khelper/105",
        "3": "udevd",
        "4": "rsyslogd",
        "5": "xinetd",
        "6": "saslauthd",
        "7": "sendmail",
        "8": "httpd",
        "9": "mingetty",
        "10": "crond",
        "12": "iptables",
        "13": "modules_dep",
        "14": "network",
        "15": "rsyslog",
        "19": "vzquota"
    },
    "autostart": ["crond", "httpd", "iptables", "modules_dep", "network", "rsyslog", "saslauthd", "sendmail", "sshd", "vzquota", "xinetd"],
    "running": {
        "1": "init",
        "2": "kthreadd/105",
        "3": "khelper/105",
        "4": "udevd",
        "5": "rsyslogd",
        "6": "xinetd",
        "7": "saslauthd",
        "9": "sendmail",
        "10": "httpd",
        "11": "sshd",
        "13": "mingetty"
    },
    "time_taken": "1.762"
}
Was this helpful to you?