Configure the GMN asynchronous processes
========================================

CNs may send various messages to MNs. These include replication requests and
System Metadata update notifications. Such requests are queued by GMN and
handled asynchronously.

The asynchronous processes are implemented as Django management commands that
are launched at regular intervals by :term:`cron`. The management commands
examine the queues and process the requests.

The asynchronous processes connect to CNs and other MNs on behalf of your GMN
instance. These connections are made over TLS/SSL and use the client side
certificate stored in ``/var/local/dataone/certs/client``.


Set up cron jobs
~~~~~~~~~~~~~~~~

  Edit the cron table for the gmn user::

    $ sudo crontab -e -u gmn

  Add::

    # Process the replication queue.
    * * * * * cd /var/local/dataone/gmn/lib/python2.7/site-packages/service && /var/local/dataone/gmn/bin/python ./manage.py process_replication_queue >>gmn_replication.log 2>&1
    # Process the System Metadata refresh queue.
    * * * * * cd /var/local/dataone/gmn/lib/python2.7/site-packages/service && /var/local/dataone/gmn/bin/python ./manage.py process_system_metadata_refresh_queue >>gmn_sysmeta.log 2>&1

  This sets the processes to run every minute. To alter the schedule, consult
  the crontab manual::

    $ man 5 crontab

Configure the GMN asynchronous processes
========================================

CNs may send various messages to MNs. These include replication requests and
System Metadata update notifications. Such requests are queued by GMN and
handled asynchronously.

The asynchronous processes are implemented as Django management commands that
are launched at regular intervals by :term:`cron`. The management commands
examine the queues and process the requests.

The asynchronous processes connect to CNs and other MNs on behalf of your GMN
instance. These connections are made over TLS/SSL and use the client side
certificate stored in ``/var/local/dataone/certs/client``.


Set up cron jobs
~~~~~~~~~~~~~~~~

  Edit the cron table for the gmn user::

    $ sudo crontab -e -u gmn

  Add::
    GMN_ROOT = /var/local/dataone/gmn
    SERVICE_ROOT = $GMN_ROOT/lib/python2.7/site-packages/service
    PYTHON_BIN = $GMN_ROOT/bin/python

    # Process the replication request queue
    0  * * * * sleep $(expr $RANDOM \% $(( 30 * 60 ))) && cd $SERVICE_ROOT && $PYTHON_BIN ./manage.py process_replication_queue >> gmn_replication.log 2>&1
    # Process the System Metadata refresh queue
    30 * * * * sleep $(expr $RANDOM \% $(( 30 * 60 ))) && cd $SERVICE_ROOT && $PYTHON_BIN ./manage.py process_refresh_queue >> gmn_sysmeta.log 2>&1

  This sets the processes to run once every hour, with a random delay that distributes network traffic and CN load over time. To alter the schedule, consult
  the crontab manual::

    $ man 5 crontab

Modify async jobs to run every hour and add random time offset
Modify async jobs to run every hour and add random time offset

GMNs async processing now occurs once per hour by default and at a
random time within the hour, to help distribute network traffic and CN
load over time.
