Code Monkey home page Code Monkey logo

laravelphp-supervisor's Introduction

Supervisor

This package provides supervisor-like, async-like, child-process-like, etc to build event-listener driven with little painless for your Laravel Project.

Getting Started

Installation :

$ composer require tripteki/laravelphp-supervisor
$ npm install pm2 && npm install --save-dev chokidar
$ pecl install swoole

How to use :

  • Publish config file into your project's directory with running :
php artisan vendor:publish --tag=tripteki-laravelphp-supervisor

Usage

php artisan supervisor:<option>

Option

  • start ... : Start the supervisor.
    • foreground (default)
    • background
  • reload : Reload the background supervisor.
  • stop : Stop the background supervisor / ctrl + c for foreground supervisor.
  • status : Show the status of background supervisor.
  • startup : Generate ecosystem.json supervisor startup configuration, do not forget to stop your supervisor process perproject, then see this to know how to get started.

Snippet

/** Use asynchronous? */

__async__(function () {

    Model::truncate();
});
/** Use asynchronous await-like to get variable? */

[ $model, ] = __async__(fn () => Model::all());
/** Use setInterval? */

__setInterval__(function () {

    Model::truncate();

}, 2000);
/** Use setImmediate? */

__setImmediate__(function () {

    Model::truncate();

}, 2000);
/** Use exec as replace temporary process? */

$os = __exec__("uname -a");
/** Use spawn as one way communication child process? */

/** Stdin stream handler... */
$stdin = fopen("php://temporary", "w+");
fwrite($stdin, "Foo...");
fwrite($stdin, "Bar...");
fwrite($stdin, "Baz...");
fclose($stdin);

/** Stdout handler... */
$stdout = function ($isError, $data)
{
    if ($isError) {

        // $isError //
    }

    // $data //
};

__spawn__("python3 example.py", $environment = [], $stdout, $stdin);

Author

laravelphp-supervisor's People

Contributors

hsbmaulana avatar

Stargazers

Jcoder avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.