<commit_before># Phusion Passenger Enterprise cloud licensing configuration

When using the [Phusion Passenger Enterprise](https://www.phusionpassenger.com/enterprise) cloud license, you are billed per server per hour. There is a mechanism which automatically reports usage to the Phusion licensing server. This is implemented by sending a certain HTTPS request to the Phusion Passenger website, https://www.phusionpassenger.com, every 15 minutes, on every server that Phusion Passenger Enterprise is running with a cloud license.

Sometimes, this manner of reporting usage data is not desirable, e.g. because of organizational security policies. For example, the servers that run Phusion Passenger Enterprise might block all outgoing traffic, or the network intrusion detection system might flag the usage reports as suspicious. To address these concerns, Phusion Passenger Enterprise 4.0.54 and later provide the ability to report usage through periodic batch jobs.

## Conceptual overview

The setup works as follows:

 1. Phusion Passenger Enterprise stores usage data on the local disk, but does not send them to the Phusion licensing server.
 2. On each server that runs Phusion Passenger Enterprise, a batch job A generates a package from the usage data that's stored on disk.
 3. All these packages are copied to another machine (let's call this "Reporter"), e.g. through SCP, USB stick, etc. The reporter machine may be any machine that you choose, as long as it can access the Phusion licensing server. The method of copying does not matter.
 4. On the reporter machine, a batch job B uploads all these packages to the Phusion licensing server.

![Conceptual overview](images/cloud_licensing_batch_job.png)

## Phase 1: setting up web servers

Follow these instructions on each server running Phusion Passenger Enterprise with a cloud license.

 1. Login to the web server and open a superuser shell. For example:

        bash$ sudo -H bash

    Or, if you're an RVM user, use rvmsudo instead of sudo:

        bash$ rvmsudo -H bash

 2. Add the following configuration to your Apache or Nginx configuration file:

        # Apache
        PassengerCtl licensing_data_points_auto_send false

        # Nginx
        passenger_ctl licensing_data_points_auto_send false;

    Then restart Apache/Nginx. This configuration tells Phusion Passenger Enterprise not to automatically send usage data to the Phusion licensing server.

 3. Find out what user the Passenger core process is running as.

    First, look for the PID of the Passenger core process.

        bash# passenger-memory-stats
        ...
        ------ Passenger processes ------
        PID    VMSize     Resident  Name
        ---------------------------------
        11243  2405.8 MB  2.7 MB    PassengerAgent: core
        ...

    Then use `ps` to determine what user it's running as. Usually, it's running as root.

        bash# ps -o pid,user -p 11243
          PID USER
        11245 root

 4. Create a directory in which to store usage data packages. For example:

        bash# mkdir /var/lib/passenger-enterprise-usage

    Ensure that it's owned by the user that the core runs as, and make it owner-accessible only:

        bash# chown root: /var/lib/passenger-enterprise-usage
        bash# chmod 700 /var/lib/passenger-enterprise-usage

 5. Create a script inside the previous directory for generating a usage data package, and for copying packages to the reporter machine. This script is part of batch job A.

        bash# touch /var/lib/passenger-enterprise-usage/script
        bash# chmod +x /var/lib/passenger-enterprise-usage/script
        bash# editor /var/lib/passenger-enterprise-usage/script
<commit_msg>Fix process name in CloudLicensingConfiguration document<commit_after># Phusion Passenger Enterprise cloud licensing configuration

When using the [Phusion Passenger Enterprise](https://www.phusionpassenger.com/enterprise) cloud license, you are billed per server per hour. There is a mechanism which automatically reports usage to the Phusion licensing server. This is implemented by sending a certain HTTPS request to the Phusion Passenger website, https://www.phusionpassenger.com, every 15 minutes, on every server that Phusion Passenger Enterprise is running with a cloud license.

Sometimes, this manner of reporting usage data is not desirable, e.g. because of organizational security policies. For example, the servers that run Phusion Passenger Enterprise might block all outgoing traffic, or the network intrusion detection system might flag the usage reports as suspicious. To address these concerns, Phusion Passenger Enterprise 4.0.54 and later provide the ability to report usage through periodic batch jobs.

## Conceptual overview

The setup works as follows:

 1. Phusion Passenger Enterprise stores usage data on the local disk, but does not send them to the Phusion licensing server.
 2. On each server that runs Phusion Passenger Enterprise, a batch job A generates a package from the usage data that's stored on disk.
 3. All these packages are copied to another machine (let's call this "Reporter"), e.g. through SCP, USB stick, etc. The reporter machine may be any machine that you choose, as long as it can access the Phusion licensing server. The method of copying does not matter.
 4. On the reporter machine, a batch job B uploads all these packages to the Phusion licensing server.

![Conceptual overview](images/cloud_licensing_batch_job.png)

## Phase 1: setting up web servers

Follow these instructions on each server running Phusion Passenger Enterprise with a cloud license.

 1. Login to the web server and open a superuser shell. For example:

        bash$ sudo -H bash

    Or, if you're an RVM user, use rvmsudo instead of sudo:

        bash$ rvmsudo -H bash

 2. Add the following configuration to your Apache or Nginx configuration file:

        # Apache
        PassengerCtl licensing_data_points_auto_send false

        # Nginx
        passenger_ctl licensing_data_points_auto_send false;

    Then restart Apache/Nginx. This configuration tells Phusion Passenger Enterprise not to automatically send usage data to the Phusion licensing server.

 3. Find out what user the Passenger core process is running as.

    First, look for the PID of the Passenger core process.

        bash# passenger-memory-stats
        ...
        ------ Passenger processes ------
        PID    VMSize     Resident  Name
        ---------------------------------
        11243  2405.8 MB  2.7 MB    Passenger: core
        ...

    Then use `ps` to determine what user it's running as. Usually, it's running as root.

        bash# ps -o pid,user -p 11243
          PID USER
        11245 root

 4. Create a directory in which to store usage data packages. For example:

        bash# mkdir /var/lib/passenger-enterprise-usage

    Ensure that it's owned by the user that the core runs as, and make it owner-accessible only:

        bash# chown root: /var/lib/passenger-enterprise-usage
        bash# chmod 700 /var/lib/passenger-enterprise-usage

 5. Create a script inside the previous directory for generating a usage data package, and for copying packages to the reporter machine. This script is part of batch job A.

        bash# touch /var/lib/passenger-enterprise-usage/script
        bash# chmod +x /var/lib/passenger-enterprise-usage/script
        bash# editor /var/lib/passenger-enterprise-usage/script

{'fraction_non_alphanumeric': 0.059044551798174985, 'fraction_numerical': 0.011003757380568975, 'mean_word_length': 3.215497737556561, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2256707', 'n_tokens_mistral': 1969, 'n_tokens_neox': 1787, 'n_words': 969}