php-doc-en/reference/win32service/functions/win32-start-service-ctrl-dispatcher.xml
Christoph Michael Becker 767ded9aed Win32Service Doc update
Patch provided by jbnahan.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@346737 c90b9560-bf6c-de11-be94-00142212c4b1
2019-02-07 12:03:02 +00:00

180 lines
5.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- Generated by xml_proto.php v2.3. Found in /scripts directory of phpdoc. -->
<refentry xml:id="function.win32-start-service-ctrl-dispatcher" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>win32_start_service_ctrl_dispatcher</refname>
<refpurpose>Registers the script with the SCM, so that it can act as the service with the given name</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>mixed</type><methodname>win32_start_service_ctrl_dispatcher</methodname>
<methodparam><type>string</type><parameter>name</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>gracefulMode</parameter><initializer>true</initializer></methodparam>
</methodsynopsis>
<para>
When launched via the Service Control Manager, a service process is
required to "check-in" with it to establish service monitoring and
communication facilities. This function performs the check-in by spawning
a thread to handle the lower-level communication with the service control
manager.
</para>
<para>
Once started, the service process should do 2 things. The first is to tell
the Service Control Manager that the service is running. This is achieved
by calling <function>win32_set_service_status</function> with the
<constant>WIN32_SERVICE_RUNNING</constant> constant. If you need to perform
some lengthy process before the service is actually running, then you can
use the <constant>WIN32_SERVICE_START_PENDING</constant> constant. The
second is to continue to check-in with the service control manager so that
it can determine if it should terminate. This is achieved by periodically
calling <function>win32_get_last_control_message</function> and handling the
return code appropriately.
</para>
<caution>
<para>
Since version 0.2.0, this function work only in "cli" SAPI. On other SAPI
this function is disabled.
</para>
</caution>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>name</parameter></term>
<listitem>
<para>
The short-name of the service, as registered by
<function>win32_create_service</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>gracefulMode</parameter></term>
<listitem>
<para>
&true; for exit graceful. &false; for exit with error. See
<function>win32_set_service_exit_mode</function> for more details.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&win32service.success.false.error;
</para>
</refsect1>
<refsect1 role="errors"><!-- {{{ -->
&reftitle.errors;
<para>
If SAPI is not <literal>"cli"</literal>, this function emits an <constant>E_ERROR</constant> level error.
</para>
</refsect1><!-- }}} -->
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A <function>win32_start_service_ctrl_dispatcher</function> example</title>
<para>
Check if the service is runnig under the SCM.
</para>
<programlisting role="php">
<![CDATA[
<?php
if (!win32_start_service_ctrl_dispatcher('dummyphp')) {
die("I'm probably not running under the service control manager");
}
win32_set_service_status(WIN32_SERVICE_START_PENDING);
// Some lengthy process to get this service up and running.
win32_set_service_status(WIN32_SERVICE_RUNNING);
while (WIN32_SERVICE_CONTROL_STOP != win32_get_last_control_message()) {
# do some work here, trying not to take more than around 30 seconds
# before coming back into the loop again
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="changelog"><!-- {{{ -->
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>0.4.0</entry>
<entry>
The parameter <parameter>gracefulMode</parameter> has been added.
</entry>
</row>
<row>
<entry>0.2.0</entry>
<entry>
This function works only in the <literal>"cli"</literal> SAPI.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1><!-- }}} -->
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>win32_set_service_status</function></member>
<member><function>win32_get_last_control_message</function></member>
<member><function>win32_set_service_exit_mode</function></member>
<member><function>win32_set_service_exit_code</function></member>
<member><link linkend="win32service.constants.errors">Win32 Error Codes</link></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->