Facron – fanotify cron system

The filesystem cron principle

At Clever Cloud, we often have to manage stuff based on filesystem events. In order to react dynamically, we will sometimes have to reload some specific configurations when the config file has changed, or we'll want to wrap some files which just appeared to grab them in the global flow.

Filesystem crons allow you to do this kind of things. What you have to do is specify the files you want to monitor with the events you want to react to and the action you want to proceed when those events occur.

Incron

Incron is the filesystem cron we've been using so far. It's based on the inotify linux system. Inotify was the replacement to dnotify which has been deprecated for quite a long time now. Thanks to inotify, incron watches for filesystem changes and act accordingly, given the configuration file you provide.

Incron does not support FUSE which is used by several filesystems, since inotify doesn't support it either.

We experienced quite a few instabilities with incron which was not as reliable as we expected, ending up with ugly bash hacks to do the job correctly. That's why I decided we needed our own solution.

Facron

Facron is my vision of the filesystem cron problematic. It is based on the "new" fanotify ABI which is more reliable and have better performances than the now deprecated inotify one. I started to write it two days ago, it's at a stage where it's usable. It's not yet perfect and I want to improve it a little but you already can try it.

The configuration file (/etc/facron.conf) looks like:

/path/to/a/file FAN_MODIFY|FAN_EVENT_ON_CHILD /path/to/script fromFacron $$

The first element is the file or directory to watch (of course multiple lines are supported), the second one corresponds to all fanotify events that you want to follow, and then your script or application (full path is recommended) + arguments. "$$" is a special token which will be replaced by the full path of the file which has emitted the event.

The available fanotify events are:

  • FAN_ACCESS
  • FAN_MODIFY
  • FAN_CLOSE_WRITE
  • FAN_CLOSE_NOWRITE
  • FAN_OPEN
  • FAN_Q_OVERFLOW
  • FAN_OPEN_PERM
  • FAN_ACCESS_PERM
  • FAN_ONDIR
  • FAN_EVENT_ON_CHILD
  • FAN_CLOSE
  • FAN_ALL_EVENTS
  • FAN_ALL_PERM_EVENTS
  • FAN_ALL_OUTGOING_EVENTS

Two more special tokens will appear: "$@" which will contain the dirname of the file, and "$#" which will contain its basename.

A systemd service file and a release tarball will be provided soon.

You can reload the configuration at any time by sending a SIGUSR1 to facron:

kill -USR1 $(pidof facron)

You can get the code on github :

Blog

À lire également

Create your own MCP client/server: as easy as 1-2-3 with Otoroshi

While Otoroshi with LLM already allows you to simplify the management of your various AI providers, access to models and integration with your teams, we have added simplified management of MCP clients and servers.
Company

Clever Cloud obtains HDS (Health Data Hosting) certification

Clever Cloud achieves HDS Certification, enabling it to host health data in France. Clever Cloud, Europe's leading provider of Platform as a Service cloud solutions, today announced that it has been awarded the Hébergeur de Données de Santé (HDS) certification, in its updated version effective May 16, 2024, for all 6 activities in the standard. This certification reinforces Clever Cloud's position as a trusted partner for companies and organizations in the healthcare sector.
Press

Clever Tools: a year of enhancements for your deployments, on the road to v4

A command line interface (CLI) is at the core of developer experience. At Clever Cloud, we have been providing Clever Tools for almost 10 years.
Engineering Features