Difference between revisions of "Daemons and Services/fr"

From Lazarus wiki
Jump to navigationJump to search
Line 6: Line 6:
 
Avec Free Pascal, Lazarus il est possible d'écrire cette plate-forme de daemons/services indépendante au travers du paquet lazdaemon de Lazarus. Pour éviter les conflits de nom avec les composants de Delphi ces classes sont appelées 'daemons'.
 
Avec Free Pascal, Lazarus il est possible d'écrire cette plate-forme de daemons/services indépendante au travers du paquet lazdaemon de Lazarus. Pour éviter les conflits de nom avec les composants de Delphi ces classes sont appelées 'daemons'.
  
=Install LazDaemon=
+
=Installer LazDaemon=
  
Before you can start, install the lazdaemon package. Either via Components / Configure installed packages or by opening/installing the lpk file directly: lazarus/components/daemon/lazdaemon.lpk.
+
Avant de pouvoir commencer, installer le paquet lazdaemon. Soit à travers '''Paquet -> Configurer les paquets installés...''' ou en ouvrant/installant le fichier lpk directement: lazarus/components/daemon/lazdaemon.lpk.
This package installs some new components and menu items in the IDE.
+
Ce paquet installe quelques nouveaux composants et des éléments de menu dans l'IDE.
  
 
=Classes=
 
=Classes=

Revision as of 12:02, 16 July 2009

English (en) español (es) français (fr) polski (pl) português (pt) русский (ru)

Que sont les daemons("service" Unix) et les services(windows)?

Les daemons Unix et les services windows sont des programmes fonctionnant sans interaction de l'utilisateur. Par exemple les serveurs www ou ftp sont appelés des daemons sous linux et des services sous windows. Parce qu'ils n'ont pas d'interaction avec l'utilisateur directement, ils ferment leurs descripteurs stdin, stdout, stderr au démarrage.

Avec Free Pascal, Lazarus il est possible d'écrire cette plate-forme de daemons/services indépendante au travers du paquet lazdaemon de Lazarus. Pour éviter les conflits de nom avec les composants de Delphi ces classes sont appelées 'daemons'.

Installer LazDaemon

Avant de pouvoir commencer, installer le paquet lazdaemon. Soit à travers Paquet -> Configurer les paquets installés... ou en ouvrant/installant le fichier lpk directement: lazarus/components/daemon/lazdaemon.lpk. Ce paquet installe quelques nouveaux composants et des éléments de menu dans l'IDE.

Classes

TCustomDaemon

This is a TDataModule descendant that does all the work. There can be several TCustomDaemons classes and/or instances running at the same time and in the same process (multi threaded).

TCustomDaemonApplication

This is a TCustomApplication descendant which creates the TCustomDaemons. This does not need any change. It runs under windows until it receives the Stop call or under linux until the TERM signal.

TDaemonMapper

This component handles the service registration. Each instance needs one entry in the property DaemonDefs.

Daemon - Step by Step

  • When the daemon is started the command line parameters are parsed. The following are predefined:
    • -i --install: register the daemon. This has no effect under unix.
    • -u --uninstall: unregister the daemon. This has no effect under unix.
    • -r --run: start the daemon. Windows does this normally itself.
  • Create the TDaemonMapper
  • Create one TCustomDaemon for each entry of DaemonDefs.
  • install, uninstall or run every instance.
  • if run: start every instance in its own thread and then wait for Stop/TERM signal.

Daemon Methods

Start

Called when daemon should start. This method must return immediately with True.

Stop

Called when daemon should stop. This method must return immediately with True.

Shutdown

Called when daemon should be killed. This method must stop the daemon immediately and return with True. This is not triggered under Linux. Linux simply kills the daemon.

Pause

Called when daemon should pause. This method must return immediately with True. Under Linux this is not triggered because the kernel stops the whole daemon on STOP and continues it on CONT.

Continue

Called when daemon should continue after a pause. This method must return immediately with True. Under Linux this is not triggered.

Install

Called when daemon is registered as windows service. This method should return True on success.

Uninstall

Called when daemon is unregistered as windows service. This method should return True on success.

AfterUnInstall

Called after daemon was unregistered as windows service. This method should return True on success.

HandleCustomCode

Called when a special signal was sent to the daemon. This method should return True on success.

Getting Started

Before you are able to create a Service or Daemon application you must first ensure that the Lazarus Daemon package "lazdaemon" is installed.

Example

There is a simple example in examples/cleandir/. Read the README.txt.


Office Automation