gws.server.monitor

Server monitor, which watches files and runs periodic tasks.

Source code: gws.server.monitor

Module Contents

gws.server.monitor.DEFAULT_FREQUENCY = 30
class gws.server.monitor.Object

Bases: gws.ServerMonitor

Server monitor.

dirs: list

Watched directories, as tuples of directory, file pattern and recursive flag.

enabled: bool

Not used.

files: list

Watched files.

frequency: int

Default interval of periodic tasks in seconds.

tasks: list[_Task]

Registered periodic tasks.

watcher: gws.lib.watcher.Watcher

File watcher, created on start unless disableWatch is set.

configure()

Configuration hook.

Called when the node is initialized. Raising an exception here aborts the creation of the node.

register_periodic_task(obj, frequency=0)

Register an object as a periodic task handler.

Parameters:
  • obj – A node with a periodic_task method.

  • frequency – Interval between runs in seconds, the monitor default if 0.

Raises:

gws.Error – If the object has no periodic_task method.

schedule_reload(with_reconfigure=False)

Schedule a reload of the web and spool backends.

The reload is performed by the monitor on its next tick.

Parameters:

with_reconfigure – Reconfigure the server before reloading.

start()

Start watching files and register the timer that drives the monitor.

Must be called in a uWSGI process.

watch_directory(dirname, pattern, recursive=False)

Add a directory to watch.

Parameters:
  • path – Directory path.

  • pattern – Regex pattern for file names to watch.

  • recursive – Also watch subdirectories.

watch_file(path)

Add a file to watch.

Parameters:

path – File path.