All Projects → php-comrade → comrade-dev

php-comrade / comrade-dev

Licence: MIT License
Comrade is a job scheduler&manager service.

Programming Languages

PHP
23972 projects - #3 most used programming language
typescript
32286 projects
HTML
75241 projects
shell
77523 projects
javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to comrade-dev

Go Quartz
Simple, zero-dependency scheduling library for Go
Stars: ✭ 118 (+71.01%)
Mutual labels:  job, job-scheduler, job-queue
orkid-node
Reliable and modern Redis Streams based task queue for Node.js 🤖
Stars: ✭ 61 (-11.59%)
Mutual labels:  job, job-scheduler, job-queue
Bull
Premium Queue package for handling distributed jobs and messages in NodeJS.
Stars: ✭ 11,748 (+16926.09%)
Mutual labels:  job, job-queue
Factotum
A system to programmatically run data pipelines
Stars: ✭ 158 (+128.99%)
Mutual labels:  job, job-scheduler
Remit
RabbitMQ-backed microservices supporting RPC, pubsub, automatic service discovery and scaling with no code changes.
Stars: ✭ 24 (-65.22%)
Mutual labels:  microservice, service
Jiacrontab
简单可信赖的任务管理工具
Stars: ✭ 1,052 (+1424.64%)
Mutual labels:  job, job-scheduler
Workq
Job server in Go
Stars: ✭ 1,546 (+2140.58%)
Mutual labels:  job, job-scheduler
Besticon
Favicon service written in Go
Stars: ✭ 472 (+584.06%)
Mutual labels:  microservice, service
Bee Queue
A simple, fast, robust job/task queue for Node.js, backed by Redis.
Stars: ✭ 2,685 (+3791.3%)
Mutual labels:  job-scheduler, job-queue
Confluence
Torrent client as a HTTP service
Stars: ✭ 126 (+82.61%)
Mutual labels:  microservice, service
Paysuper Billing Server
A core monolith-like service with all payment processing business logic in PaySuper.
Stars: ✭ 95 (+37.68%)
Mutual labels:  microservice, service
nest-queue
Queue manager for NestJS Framework for Redis (via bull package)
Stars: ✭ 69 (+0%)
Mutual labels:  job, job-scheduler
Antares
分布式任务调度平台(Distributed Job Schedule Platform)
Stars: ✭ 558 (+708.7%)
Mutual labels:  job, job-scheduler
Hangfire.httpjob
httpjob for Hangfire,restful api for Hangfire,job调度与业务分离
Stars: ✭ 366 (+430.43%)
Mutual labels:  job, job-scheduler
Swiftqueue
Job Scheduler for IOS with Concurrent run, failure/retry, persistence, repeat, delay and more
Stars: ✭ 276 (+300%)
Mutual labels:  job, job-scheduler
Typescript Rest
This is a lightweight annotation-based expressjs extension for typescript.
Stars: ✭ 458 (+563.77%)
Mutual labels:  microservice, service
Node Job Queue
Implementation of a nested asynchronous job queue in Node.js
Stars: ✭ 56 (-18.84%)
Mutual labels:  job-scheduler, job-queue
Fiber Job System
Multi-Threaded Job System using Fibers
Stars: ✭ 121 (+75.36%)
Mutual labels:  job-scheduler, job-queue
S
a go web freamwork for micro service, very very easy to create and deploy, with auto service registry and discover, high performance and based on http/2 no ssl
Stars: ✭ 67 (-2.9%)
Mutual labels:  microservice, service
agendash-v2
A modern, secure, and reliable dashboard for Agenda with search and pagination capabilities written in vue.js
Stars: ✭ 27 (-60.87%)
Mutual labels:  job-scheduler, job-queue

Comrade

Comrade is a job scheduler&manager service.

Features

  • Exclusive jobs
  • Dependent jobs
  • Sub jobs execution
  • Cron triggers
  • Simple triggers
  • Worker execution grace period (i.e. timeout)
  • Queue and HTTP runners
  • Hybrid API. Supports HTTP and MQ API
  • JSON Schemas for everything
  • Real-time, WEB based UI
  • Write worker in any language
  • Standalone service
  • Containerized, easy to deploy
  • Work with any Queue Interop compatible queue
  • A client for PHP.

Online Demo

The Comrade UI is available at http://demo.comrade.forma-pro.com and the service itself is at http://demo.comrade.forma-pro.com:81.

Installation

The best way to run Comrade in production is to use pre-build Docker containers.

  1. Create an empty directory

  2. Inside, create an .env file with content:

    APP_ENV=prod
    APP_DEBUG=0
    APP_SECRET=45402ed3d65de420f63e1546c322968c
    ENQUEUE_DSN=amqp+bunny://comrade:comrade123@rabbitmq:5672/comrade?receive_method=basic_consume&lazy=1&qos_prefetch_count=3&persisted=1&connection_timeout&connection_timeout=20
    MONGO_DSN=mongodb://mongo:27017/comrade
    WAMP_DSN=ws://jms:9090
    WAMP_REALM=realm1
    WAMP_SERVER_HOST=0.0.0.0
    WAMP_SERVER_PORT=9090
    
  3. Create docker-compose.yml file with next content:

    version: '3'
    
    services:
      jm:
        image: 'formapro/comrade:latest'
        ports:
          - "81:80"
        depends_on:
          - 'rabbitmq'
          - 'mongo'
        env_file: '/.env'
    
      jmc:
        image: 'formapro/comrade:latest'
        entrypoint: 'php bin/console enqueue:consume --setup-broker --receive-timeout=10000 --memory-limit=100 -vvv'
        depends_on:
          - 'rabbitmq'
          - 'mongo'
        env_file: '/.env'
    
      jmq:
        image: 'formapro/comrade:latest'
        entrypoint: 'php bin/console quartz:scheduler -vvv'
        depends_on:
          - 'rabbitmq'
          - 'mongo'
        env_file: '/.env'
        deploy:
          mode: 'global'
          
      jmw:
        image: 'formapro/comrade:latest'
        entrypoint: 'php bin/wamp_server.php'
        depends_on:
          - 'rabbitmq'
          - 'mongo'
        env_file: '/.env'
        ports:
          - '9090:9090'
    
      ui:
        image: 'formapro/comrade-ui:latest'
        ports:
          - "80:80"
    
      rabbitmq:
        image: 'rabbitmq:latest'
        environment:
          - 'RABBITMQ_DEFAULT_USER=comrade'
          - 'RABBITMQ_DEFAULT_PASS=comrade123'
          - 'RABBITMQ_DEFAULT_VHOST=comrade'
    
      mongo: { image: 'mongo:3' }
  4. Run docker-compose up. Now you have the comrade server available at localhost:81, UI at localhost:80, websocket server at localhost:9090.

If you'd like to build and run Comrade from source code, do next:

$ git clone [email protected]:php-comrade/comrade-dev.git;
$ (cd comrade-dev/apps/jm; composer install);
$ (cd comrade-dev/apps/demo; composer install);
$ (cd comrade-dev/apps/ui; npm install);
$ echo '127.0.0.1 jm.loc' >> /etc/hosts
$ echo '127.0.0.1 ui.jm.loc' >> /etc/hosts
$ bin/dup

The Comrade service will be available at jm.loc host and its UI at ui.jm.loc.

PHP client.

The Comrade exposes for various things like create job, add trigger, query jobs operations. They are available through HTTP as well as message queue. Same format. It is possible to create job from any programming language as well as run it later. For PHP we provide a simple client

composer require comrade/client:*@dev 

With the client you can create a job by doing:

<?php
use Comrade\Shared\Model\JobTemplate;
use Comrade\Shared\Model\QueueRunner;
use Comrade\Shared\Model\GracePeriodPolicy;
use Comrade\Shared\Message\CreateJob;
use Comrade\Shared\Model\CronTrigger;
use Enqueue\Util\UUID;
use Enqueue\Util\JSON;
use function Enqueue\dsn_to_context;
use function Makasim\Values\register_cast_hooks;
use function Makasim\Values\register_object_hooks;
use Interop\Queue\PsrContext;

require_once __DIR__.'/vendor/autoload.php';

register_cast_hooks();
register_object_hooks();

/** @var PsrContext $queueContext */
$context = dsn_to_context(getenv('ENQUEUE_DSN'));

$template = JobTemplate::create();
$template->setName('demo_success_job');
$template->setTemplateId(Uuid::generate());
$template->setRunner(QueueRunner::createFor('demo_success_job'));

$policy = GracePeriodPolicy::create();
$policy->setPeriod(20);
$template->setGracePeriodPolicy($policy);

$trigger = CronTrigger::create();
$trigger->setTemplateId($template->getTemplateId());
$trigger->setStartAt(new \DateTime('now'));
$trigger->setMisfireInstruction(CronTrigger::MISFIRE_INSTRUCTION_FIRE_ONCE_NOW);
$trigger->setExpression('*/5 * * * *');

$createJob = CreateJob::createFor($template);
$createJob->addTrigger($trigger);

$queue = $context->createQueue('comrade_create_job');
$message = $context->createMessage(JSON::encode($createJob));
$context->createProducer()->send($queue, $message);

Job has QueueRunner. It means that when it is time to run the job it is sent to demo_success_job queue. Job has GracePeriodPolicy. It means that if the job is not finished within 20 seconds it is marked as failed. Job has CronTrigger. It means the job should be run every five minutes.

There is possibility to set other polices, triggers or another runner. The job worker could look like this:

<?php

use Comrade\Shared\Message\RunJob;
use Comrade\Shared\Model\JobAction;
use Comrade\Client\ClientQueueRunner;
use Interop\Queue\PsrContext;
use Interop\Queue\PsrMessage;
use function Enqueue\dsn_to_context;
use Enqueue\Consumption\QueueConsumer;
use Enqueue\Consumption\Result;
use function Makasim\Values\register_cast_hooks;
use function Makasim\Values\register_object_hooks;

register_cast_hooks();
register_object_hooks();

/** @var PsrContext $c */
$c = dsn_to_context(getenv('ENQUEUE_DSN'));

$runner = new ClientQueueRunner($c);

$queueConsumer = new QueueConsumer($c);

$queueConsumer->bind('demo_success_job', function(PsrMessage $message) use ($runner) {
    $runner->run($message, function(RunJob $runJob) {
        // do your stuff here. 

        return JobAction::COMPLETE;
    });

    return Result::ACK;
});

$queueConsumer->consume();

Developed by Forma-Pro

Forma-Pro is a full stack development company which interests also spread to open source development. Being a team of strong professionals we have an aim an ability to help community by developing cutting edge solutions in the areas of e-commerce, docker & microservice oriented architecture where we have accumulated a huge many-years experience. Our main specialization is Symfony framework based solution, but we are always looking to the technologies that allow us to do our job the best way. We are committed to creating solutions that revolutionize the way how things are developed in aspects of architecture & scalability.

If you have any questions and inquires about our open source development, this product particularly or any other matter feel free to contact at [email protected]

License

It is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].