Software Development Kit

cPanel & WHM's API [+] cPanel & WHM's API [-]


Modules and Plugins [+] Modules and Plugins [-]


cPanel & WHM Hooks [+] cPanel & WHM Hooks [-]


cPAddons (Site Software) [+] cPAddons (Site Software) [-]


System Administration [+] System Administration [-]


Developer Software [+] Developer Software [-]


Back to All Documentation

Restart Service — restartservice

This function restarts a service (daemon) on the server.

Calling Functions

Using the XML API

To use the XML API to perform the restartservice function from within your custom script:

  • Append the /xml-api/restartservice function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/xml-api/restartservice

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Using the JSON API

To use the JSON API to perform the restartservice function from within your custom script:

  • Append the /json-api/restartservice function call name, plus the required variables (see below), to a URL which includes the address of your server.

  • For example, on a server whose hostname is example.com, you would include the following string in your script: https://example.com:2087/json-api/restartservice

  • You need to be logged in with the proper permissions in order to call a function. See our document about Authenticating API Function Calls for more information about authenticating APIs from within a script.

  • You can also perform the function by entering the string in your web browser's address bar. This may be useful for testing the function call and viewing its output.

Variables

Input

The restartservice function takes the following required variable as input:

  • service — The service you wish to restart. Acceptable values:
    • named
    • interchange
    • ftpd
    • httpd
    • imap
    • cppop
    • exim
    • mysql
    • postgresql
    • sshd
    • tomcat

Output

Show Hide
  • restartservice — Root-level XML tag for the output of the restartservice function.
    • restart — The content of the restart call.
      • rawout — Raw HTML output of the restart command.
      • result — Result of the restart.
        • 1 — success.
        • 0 — failure.
      • service — Short name of the service.
      • servicename — Full name of the service. Possible values:
        • DNS Server (BIND)
        • Interchange Server
        • Ftp Service (ProFTPd/Pure-FTPd)
        • Apache Web Server
        • IMAP Server (Courier IMAP/WU IMAP)
        • POP3 Server (Courier POP3/cppop)
        • Exim Mail
        • MySQL Server
        • PostgresSQL Server
        • SSH Daemon
        • Tomcat Server

Examples

XML API

Show Hide

Calling the URL https://example.com:2087/xml-api/restartservice?service=httpd in WebHost Manager will produce output similar to:

<restartservice>
     <restart>
            <rawout>Waiting for httpd to restart..............finished.
            httpd (/usr/local/apache/bin/httpd -k start -DSSL) 
            running as root with PID 19446
            httpd (/usr/local/apache/bin/httpd -k start -DSSL) 
            running as root with PID 19452
            httpd started ok
            </rawout>
            <result>1</result>
            <service>httpd</service>
            <servicename>Apache Web Server</servicename>
      </restart>
</restartservice>

JSON API

Show Hide

Calling the following function in WebHost Manager: https://example.com:2087/json-api/restartservice?service=httpd will produce output similar to:

{
   "restart":[
      {
         "result":1,
         "service":"httpd",
         "rawout":"Waiting for httpd to restart..............finished.\n\nhttpd 
(/usr/local/apache/bin/httpd -k start -DSSL) running as root with PID 21379\n
httpd (/usr/local/apache/bin/httpd -k start -DSSL) running as root with PID 21385
\n\nhttpd started ok\n",
         "servicename":"Apache Web Server"
      }
   ]
}

Topic revision: r7 - 29 Sep 2009 - 19:06:43 - MelanieSeibert