2017 © Pedro Peláez
 

project xmlnuke-cmdline

Run XMLNuke modules and classes in command line as batches and daemon/service

image

byjg/xmlnuke-cmdline

Run XMLNuke modules and classes in command line as batches and daemon/service

  • Tuesday, May 26, 2015
  • by byjg
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

XMLNuke Command Line Project

Enables run an existing XMLNuke module from the command line without to make changes in your module., (*1)

Install

Project Level, (*2)

composer require "byjg/xmlnuke-cmdline=dev-master"

Entire System, (*3)

composer global require "byjg/xmlnuke-cmdline=dev-master"

Usage

The syntax is:, (*4)

runxmlnuke.php SCRIPT PARAMETERS

for example:, (*5)

runxmlnuke.php xmlnuke <FOLDER_APP> module=Lesson1.Sample1 raw=json xpath=//mediaitem

The parameter SCRIPT can be:, (*6)

  • xmlnuke - Run a typical XMLNuke module with all parameters
  • ws - Run a class that implements a SOAP interface. See more here.
  • daemon - Create a Linux Daemon Service. More details below.

Running a SOAP Service

The SOAP service in command line only work invoking the web method through a GET request. The command line will be something like:, (*7)

runxmlnuke.php ws <FOLDER_APP> ws=/Lesson1.SOAP.SampleWebService svc=getEcho "text=Some Text"

Create Daemon/Services with XMLNuke

A Service is a program that runs infinitely. You can create a service in XMLNuke by implementing a class with a method execute(). This method, does not need to create a Loop. XMLNuke will do a loop for you., (*8)

Example:, (*9)

namespace Lesson1\Classes;

class Service
{
    protected $loop = 0;

    public function execute()
    {
        $this->loop++;
        echo $this->loop ."\n";

        return true;
    }

}

This method must return true to continue the service or false to stop it. To run this daemon:, (*10)

sudo runxmlnuke.php daemon service=Lesson1.Classes.Service &

The service will run silently, but will create TWO log files: * /var/log/xmlnuke.daemon/Lesson1.Classes.Service.log - All output from the service * /var/log/xmlnuke.daemon/Lesson1.Classes.Service.error.log - All errors generated by the service., (*11)

Create a init service

You can create a service in the Linux system just copying this file inside the folder /etc/init, (*12)

Example: sample.conf, (*13)

description "Sample Daemon"
author      "JG"

# used to be: start on startup
# until we found some mounts weren't ready yet while booting:
start on started mountall
stop on shutdown

# Automatically Respawn:
respawn
respawn limit 99 5

exec /opt/xmlnuke/utils/cmdline/runxmlnuke.sh daemon <FOLDER_YOUR_APP> service=Lesson1.Classes.Service

Now you can start or stop the service using:, (*14)

service sample start

or, (*15)

service sample stop

Putting all together

  • Service: https://github.com/byjg/xmlnuke-lesson1/blob/master/lib/Lesson1/Classes/Service.class.php
  • Init Conf: https://github.com/byjg/xmlnuke-lesson1/blob/master/conf/sample.conf

The Versions

26/05 2015

dev-develop

dev-develop http://xmlnuke.com

Run XMLNuke modules and classes in command line as batches and daemon/service

  Sources   Download

GPL

The Requires

 

by João Gilberto Magalhães

api framework json xml command line shell xsl xmlnuke

14/05 2015

dev-master

9999999-dev http://xmlnuke.com

Run XMLNuke modules and classes in command line as batches and daemon/service

  Sources   Download

GPL

The Requires

 

by João Gilberto Magalhães

api framework json xml command line shell xsl xmlnuke