Server services, such as mail service, DNS service, FTP and so on, can be started, stopped and restarted via both Plesk GUI and Plesk XML API protocol. To start, stop or restart a particular service, use the srv_man operation.

To get information on the current state of the server services (whether each is started or stopped at the moment), use the get operation with services_state parameter specified.

Request Packet Structure

A request XML packet starting, stopping or restarting server services contains the srv_man operation node:

<packet>
  <server>
    <srv_man>
      ...
    </srv_man>
  </server>
</packet>

The srv_man node is presented by complex type ServicesManagementType (server_input.xsd) and structured as follows:

image 37089

Note: The interactive schema navigator for all request packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_input.svg.

  • The id node is required. It specifies the ID of the service that should be started/ restarted/ stopped. Data type: srvIdType (plesk_server.xsd).
  • The operation node is required. It specifies what should be done to the server specified by the id node. Data type: srvOpType (plesk_server.xsd). Allowed values: start | stop | restart.

Note: When creating request packets, put nodes and elements in the order they follow in the packet structure.

Response Packet Structure

The srv_man node of the response packet is structured as follows:

image 37093

Note: The interactive schema navigator for all response packets is available here: http://plesk.github.io/api-schemas/1.6.8.0/agent_output.svg.

  • The result node is required. It wraps the result of the srv_man operation. Data type: ServicesManagementResultType (server_output.xsd).
  • The status node is required. It returns the execution status of the srv_man operation. Data type: string. Allowed values: ok | error.
  • The errcode node is optional. It returns the error code when the srv_man operation fails. Data type: unsignedInt.
  • The errtext node is optional. It returns the error message if the srv_man operation fails. Data type: string.
  • The id node is required if the srv_man operation succeeds. It returns the ID of the service which was successfully started, stopped or restarted. Data type: srvIdType (plesk_server.xsd).

Samples

Stopping the web and Fail2Ban services

This packet stops the web and Fail2Ban services on Linux-based servers.

<packet>
<server>
<srv_man>
   <id>web</id>
   <operation>stop</operation>
</srv_man>
 <srv_man>
      <id>fail2ban</id>
      <operation>stop</operation>
    </srv_man>
</server>
</packet>

Response:

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.7.0">
  <server>
    <srv_man>
      <result>
        <status>ok</status>
        <id>web</id>
      </result>
    </srv_man>
    <srv_man>
      <result>
        <status>ok</status>
        <id>fail2ban</id>
      </result>
    </srv_man>
  </server>
</packet>

Starting PostgreSQL and MySQL database services

This packet starts PostgreSQL and MySQL database services.

<packet>
<server>
<srv_man>
   <id>postgresql</id>
   <operation>start</operation>
</srv_man>
<srv_man>
   <id>mysql</id>
   <operation>start</operation>
</srv_man>
</server>
</packet>

Response:

<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.7.0">
  <server>
    <srv_man>
      <result>
        <status>ok</status>
        <id>postgresql</id>
      </result>
    </srv_man>
    <srv_man>
      <result>
        <status>error</status>
        <errcode>1013</errcode>
        <errtext>Service 'mysql' does not exist</errtext>
      </result>
    </srv_man>
  </server>
</packet>