The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Zing::Daemon - Process Daemon

ABSTRACT

Daemon Process Management

SYNOPSIS

  use Zing::Cartridge;
  use Zing::Daemon;

  my $daemon = Zing::Daemon->new(
    cartridge => Zing::Cartridge->new(
      name => 'example',
      scheme => ['MyApp', [], 1],
    )
  );

  # $daemon->start;

DESCRIPTION

This package provides the mechanisms for running a Zing application as a daemon process.

INHERITS

This package inherits behaviors from:

Zing::Entity

LIBRARIES

This package uses type constraints from:

Zing::Types

ATTRIBUTES

This package has the following attributes:

cartridge

  cartridge(Cartridge)

This attribute is read-only, accepts (Cartridge) values, and is required.

journal

  journal(Journal)

This attribute is read-only, accepts (Journal) values, and is optional.

kernel

  kernel(Zing)

This attribute is read-only, accepts (Zing) values, and is optional.

log_filter_from

  log_filter_from(Str)

This attribute is read-only, accepts (Str) values, and is optional.

log_filter_queries

  log_filter_queries(ArrayRef[Str])

This attribute is read-only, accepts (ArrayRef[Str]) values, and is optional.

log_filter_tag

  log_filter_tag(Str)

This attribute is read-only, accepts (Str) values, and is optional.

log_level

  log_level(Str)

This attribute is read-only, accepts (Str) values, and is optional.

log_reset

  log_reset(Bool)

This attribute is read-only, accepts (Bool) values, and is optional.

log_verbose

  log_verbose(Bool)

This attribute is read-only, accepts (Bool) values, and is optional.

logger

  logger(Logger)

This attribute is read-only, accepts (Logger) values, and is optional.

METHODS

This package implements the following methods:

fork

  fork() : Int

The fork method forks the application and returns a pid.

fork example #1
  # given: synopsis

  my $pid = $daemon->fork;

restart

  restart() : Bool

The restart method stops and then starts the application and creates a pid file under the "pidfile" in Zing::Cartridge.

restart example #1
  use FlightRecorder;
  use Zing::Cartridge;
  use Zing::Daemon;

  my $daemon = Zing::Daemon->new(
    logger => FlightRecorder->new(auto => undef),
    cartridge => Zing::Cartridge->new(
      name => 'example',
      scheme => ['MyApp', [], 1],
    )
  );

  $daemon->restart;

start

  start() : Bool

The start method forks the application and creates a pid file under the "pidfile" in Zing::Cartridge.

start example #1
  use FlightRecorder;
  use Zing::Cartridge;
  use Zing::Daemon;

  my $daemon = Zing::Daemon->new(
    logger => FlightRecorder->new(auto => undef),
    cartridge => Zing::Cartridge->new(
      name => 'example',
      scheme => ['MyApp', [], 1],
    )
  );

  $daemon->start;

stop

  stop() : Bool

The stop method stops the application and removes the pid file under the "pidfile" in Zing::Cartridge.

stop example #1
  use FlightRecorder;
  use Zing::Cartridge;
  use Zing::Daemon;

  my $daemon = Zing::Daemon->new(
    logger => FlightRecorder->new(auto => undef),
    cartridge => Zing::Cartridge->new(
      name => 'example',
      scheme => ['MyApp', [], 1],
    )
  );

  $daemon->stop;

AUTHOR

Al Newkirk, awncorp@cpan.org

LICENSE

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file".

PROJECT

Wiki

Project

Initiatives

Milestones

Contributing

Issues