An open API service indexing awesome lists of open source software.

https://github.com/formapro/crony

Lightweight cron replacement that calls URL.
https://github.com/formapro/crony

Last synced: 7 months ago
JSON representation

Lightweight cron replacement that calls URL.

Awesome Lists containing this project

README

          

# Crony

Lightweight cron replacement that calls URL

## Usage

Config

```json
{
"tasks": [
{
"cron": "@every 1m",
"url": "http://app/task"
}
]
}

```

Docker


```yaml
services:
app:

cron:
image: 'formapro/crony:latest'
depends_on:
- app
volumes:
- './crony.json:/app/crony.json'
```

Symfony

Route:

```yaml
#config/routes.yaml

cron_task:
path: '/cron/task/foo'
controller: 'App\Controller\CronTaskController::foo'
methods: [POST]
```

Controller:

```php
attributes->set('task', 'foo');

return new Response();
}

public function onTerminate(PostResponseEvent $event): void
{
if ('foo' !== $event->getRequest()->attributes->get('task')) {
return;
}

// do task
}

public static function getSubscribedEvents(): array
{
return [
KernelEvents::TERMINATE => 'onTerminate',
];
}
}
```

## License

MIT