Set up a recurring task to spawn workers

To ensure that incoming Helix Server events are automatically processed by Swarm, it is important to set up a cron job to do this. The cron job can be installed on any host, although you may want to place this on the Swarm host.

Install curl or wget

You must install either curl or wget to run the recurring task that spawns the Swarm workers:

Install curl

https://curl.haxx.se/download.html

Note

For Windows, curl.exe depends on MSVCR100.dll. You can get a copy by installing the Microsoft Visual C++ Redistributable Package, available for:

If you install Swarm with HTTPS, curl.exe requires recent CA certificates (or HTTPS connections silently fail). You can get a copy of the cacert.pem from:

https://curl.haxx.se/docs/caextract.html

Once downloaded, copy cacert.pem to the same folder where you installed curl.exe, and rename it to curl-ca-bundle.crt.

Warning

If curl (or curl.exe on Windows) cannot execute as expected, trigger execution may block or fail. For example, if MSVCR100.dll is missing from a Windows system, invoking curl.exe causes a dialog to appear.

Prior to configuring the triggers, verify that curl executes. On Linux systems, run:

 $ curl -h

On Windows systems, run:

C:\> curl.exe -h

The start of the output should be similar to:

Usage: curl [options...] <url>
Options: (H) means HTTP/HTTPS only, (F) means FTP only
     --anyauth       Pick "any" authentication method (H)
 -a, --append        Append to target file when uploading (F/SFTP)
     --cacert FILE   CA certificate to verify peer against (SSL)
     --capath DIR    CA directory to verify peer against (SSL)
...[truncated for brevity]...

For a more thorough test that actually fetches content over a network, try the following test:

The output should look like HTML.

Install wget

https://ftp.gnu.org/gnu/wget/

http://gnuwin32.sourceforge.net/packages/wget.htm (for Windows)

Note

If you are using Powershell on Windows systems, be aware that Powershell includes aliases for curl and wget that call the Powershell command Invoke-WebRequest instead of curl.exe or wget.exe. Invoke-WebRequest has different command-line options than either curl or wget, which can be confusing.

If you want to remove the built-in aliases for curl and wget from Powershell, follow these steps:

  1. Create a Powershell profile (only if you have not already done so):

     PS C:\> New-Item $profile -force -itemtype file
  2. Edit your profile:

     PS C:\> notepad $profile
  3. Add the following line to your profile:

    remove-item alias:curl
    remove-item alias:wget
  4. Save the profile and close notepad.
  5. Reload your profile:

     PS C:\> . $profile

Verify that curl or wget is installed

Warning

curl or wget must be installed or workers do not spawn and Swarm cannot process any events.

Verify that curl or wget is installed:

  1. Use the which command.
  2. For example to verify that curl is installed:

    $ which curl
  3. If you see any output, the referenced command is installed.

Create a recurring task to spawn workers

Note

Swarm package installation and Swarm OVA installation:

swarm-cron.sh script

The swarm-cron.sh file in /opt/perforce/swarm/p4-bin/scripts ensures that a worker is fired up every minute.

By default, the DEFAULT_CONFIG_FILE= configuration line is set to /opt/perforce/etc/swarm-cron-hosts.conf. The swarm-cron.sh script takes the Swarm hostname from the swarm-cron-hosts.conf file.

The swarm-cron.sh script contains the correct content for Swarm installations using wget, or curl.

Tip

You must leave the wget, and curl configuration lines in the script. The script is written so that it can be used with Swarm installations that use wget, and Swarm installations that use curl. The wget configuration line is tried first, if that fails the curl configuration line is tried.

In the wget and curl configuration lines above, where you see --timeout 5 or --max-time 5, the 5 is the number of seconds that the cron task will wait for a response from the Swarm host. When the cron task is installed on the Swarm host, such as in the Swarm OVA, that value could be reduced to 1 second (e.g. --timeout 1 or --max-time 1).

Note

If you configure Swarm to use HTTPS, and you install a self-signed certificate, the cron jobs avoid the certificate validity test which could cause silent failures to process events. The command to avoid the certificate validity test is included by default for wget, and curl:

If you have configured an HTTP connection to Swarm, the avoid validity check command is ignored.

swarm-cron-hosts.conf configuration file

The swarm-cron-hosts.conf file in /opt/perforce/etc specifies the connection type (HTTP or HTTPS), hostname, and port number for Swarm cron jobs.

  1. Edit the swarm-cron-hosts.conf file so that is contains the actual Swarm hostname, and port you have configured for Swarm (which may include a sub-folder or a custom port). The following format is used:
  2. [http[s]://]<swarm-host>[:<port>]

    Default if value not specified:

  3. Save the edited file.
  4. Tip

    To check or modify Swarm worker configuration, see Workers.

    Note

    If the recurring task is disabled, or stops functioning for any reason, logged-in users see the following error message when Swarm detects that no workers are running:

  5. Review the post-install configuration options to customize your Swarm installation, see Post-install configuration options.