Helix Core is now P4 and Helix Swarm is now P4 Code Review. Learn more >>

Documentation | 2025.2

# Set up a recurring task to spawn workers

To ensure that incoming P4 Server events are automatically processed by P4 Code Review, it is important to set up a cron job to do this. We recommend that the cron job is installed on the P4 Code Review host machine.

## Install curl or wget

You must install either curl or wget on the P4 Code Review server machine to run the recurring task that spawns the P4 Code Review workers:

- To install curl, see Install curl.
- To install wget, see Install wget.

### Install curl

1. Download curl from: curl download page
2. Install curl.
3. Verify that curl is installed, see Verify that curl or wget is installed.

If `curl` cannot execute as expected, trigger execution may block or fail. Prior to configuring the triggers, verify that `curl` executes, run:

    $ curl -h

Below is an example of the start of the output:

    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 fetches content over a network, try the following test:

    $ curl https://www.perforce.com/

The output should look like HTML.

### Install wget

1. Download wget from: wget download page
2. Install wget.
3. Verify that wget is installed, see Verify that curl or wget is installed.

## Verify that curl or wget is installed

`curl` or `wget` must be installed or workers do not spawn and P4 Code Review cannot process any events.

Verify that curl or wget is installed:

1. Use the `which` command.

For example to verify that curl is installed:

    $ which curl

2. If you see any output, the referenced command is installed.

## Create a recurring task to spawn workers

P4 Code Review package installation:

- The helix-swarm, swarm-cron-hosts.conf, and swarm-cron.sh files are automatically created with the correct content including the correct URL for P4 Code Review. They do not need to be edited.
- If you want to run P4 Code Review in a sub-folder of an existing website, or with a custom port, the swarm-cron-host.conf file must be edited. For instructions on how to configure P4 Code Review to run in a sub-folder, or with a custom port, see Run Swarm in a sub-folder of an existing web site, or Run Swarm's virtual host on a custom port.

### helix-swarm cron file

The helix-swarm file is located in the /etc/cron.d and points to the swarm-cron.sh script file.

1. Create a file named helix-swarm in /etc/cron.d if it does not already exist.
2. Edit the helix-swarm file so that it has the following content:

    #
    # Cron job to start Swarm workers every minute
    #
    * * * * * nobody [ -x /opt/perforce/swarm/p4-bin/scripts/swarm-cron.sh ] && /opt/perforce/swarm/p4-bin/scripts/swarm-cron.sh

3. Save the helix-swarm file.

### 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 P4 Code Review hostname from the swarm-cron-hosts.conf file.

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

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

- `wget` configuration line for HTTP, and HTTPS:

      wget --quiet --no-check-certificate --output-document /dev/null --timeout 5 "${SWARM_HOST}/queue/worker"

- `curl` configuration line for HTTP, and HTTPS:

      curl --silent --insecure --output /dev/null --max-time 5 "${SWARM_HOST}/queue/worker"

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 P4 Code Review host. When the cron task is installed on the P4 Code Review host, that value could be reduced to `1` second (e.g. `--timeout 1` or `--max-time 1`).

If you configure P4 Code Review 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:

- wget command: --no-check-certificate
- curl command: --insecure

If you have configured an HTTP connection to P4 Code Review, the avoid validity check command is ignored. For more information about the risks of using a self-signed SSL certificate, see Security risks of using a self-signed certificate.

### 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 P4 Code Review cron jobs.

1. Edit the `swarm-cron-hosts.conf` file so that is contains the actual P4 Code Review hostname, and port you have configured for P4 Code Review (which may include a sub-folder or a custom port). The following format is used:

    [http[s]://]<swarm-host>[:<port>]

Default if value not specified:

- [http[s]://] http
- <swarm-host> must be specified
- :<port> 80

2. Save the edited file. If the recurring task is disabled, or stops functioning for any reason, logged-in users will see an error message when P4 Code Review detects that no workers are running.

To check or modify P4 Code Review worker configuration, see Workers.

3. The basic P4 Code Review configuration is now complete.

   If your P4 Server is configured for P4 AS, you can force all of your users to authenticate via your Identity Provider (IdP) by disabling fall-back to passwords. To disable fall-back to passwords on the P4 Server, run the following command:

   p4 configure set auth.sso.allow.passwd=0

4. Review the post-install configuration options to customize your P4 Code Review installation, see Post-install configuration options.

Your search for returned results