Running an additional copy of the module

Several copies of the module can be running on one Asterisk server. They can be connected to the same telephony, but to different CRMs.

It's important:

  1. Internal numbers on portals must not overlap (otherwise one call will hit multiple portals).

  2. Each copy of the module should have its own config file and network ports for connecting to the admin area and receiving commands from CRM.

  3. Each copy of the module should have its own customizer.

  4. Licensing is done through portal addresses.

  5. When running several copies of the module on the same portal, it is possible to exceed the limit of CRM API requests (copies of the module do not coordinate the frequency of requests among themselves).

The changes are described for itgrix_bx. For itgrix_kmo everything is the same, only paths will contain itgrix_kmo instead of itgrix_bx.

Steps for creating a copy

1. Create the second config

Let's call it /etc/itgrix_bx/config-1.json

cp /etc/itgrix_bx/config{,-1}.json

We will fix it in the new config:

  • port, secure_port another port other than 8077, 8078

Example of updated values:

"port": 8075,
"secure_port": 8076,

2. Create a configuration file for the new service

cp /etc/systemd/system/itgrix_bx{,-1}.service

In the new file for systemd, make the following changes:

  • Description change to the name of the new service (itgrix_bx-1);

  • В ExecStart add a flag --config with the name of the new config that was created in step 2;

  • В ExecStart change the name of the log file to a new one.

Example of updated values:

[Unit]
Description=itgrix_bx-1

[Service]
ExecStart=/bin/sh -c "/opt/itgrix_bx/itgrix_bx --config=/etc/itgrix_bx/config-1.json >> /var/log/itgrix_bx-1.log"

3. Registration of the second service of the integration module

Run the module executable with the --register-instances switch in order for the module to detect the additional copy:

/opt/itgrix_bx/itgrix_bx --register-instances

4. Configure log rotation

We need to create a separate log file cp /var/log/itgrix_bx{,-1}.log and change its owner to the user under which the service will be started.

In /etc/logrotate.d/itgrix_bx copy the entire contents with the new log name.

New file contents:

/var/log/itgrix_bx.log {

# rotation once a day. Possible options daily, weekly, monthly, size (example size=1M)
daily

# saves the last 5 rotated files
rotate 5

# compress the rotated file
compress

# compress the previous file on the next rotation
delaycompress

# missing file is not an error
missingok

# don't create a new file, copy the contents and reset the old one.
copytruncate
}

/var/log/itgrix_bx-1.log {

# rotation once a day. Possible options daily, weekly, monthly, size (example size=1M)
daily

# saves the last 5 rotated files
rotate 5

# compress the rotated file
compress

# compress the previous file on the next rotation
delaycompress

# missing file is not an error
missingok

# don't create a new file, copy the contents and reset the old one.
copytruncate
}

5. Creating a second customizer

For the first copy of the module, the customizer is located in the folder /opt/itgrix_bx/customizer/.

In the file /opt/itgrix_bx/customizer/settings.json. The config and log of the first copy are listed.

For the second copy, create a folder /opt/itgrix_bx/customizer-1/ and in the file /opt/itgrix_bx/customizer-1/settings.json configure and log the second copy.:

{
  "configCrmField": "bitrix",
  "configPath": "/etc/itgrix_bx/config-1.json",
  "logPath": "/var/log/itgrix_bx-1.log",
  "requestTimeoutSec": 2
}

For Itgrix_kmo "configCrmField": "kmo", path values contain itgrix_kmo.

Also in the second copy's config /etc/itgrix_bx/config-1.json you need to specify the appropriate customizer:

  "customizer": {
    ...
    "program_path": "/opt/itgrix_bx/customizer-1/customize.php",
    ...
  }

Now we set up the customizations in /opt/itgrix_bx/customizer-1/actions/ according to the needs of the second copy.

6. Start/stop/restart/status/auto start

systemctl start itgrix_bx-1 systemctl stop itgrix_bx-1 systemctl restart itgrix_bx-1 systemctl status itgrix_bx-1 systemctl enable itgrix_bx-1 systemctl disable itgrix_bx-1

7. Authorize on the portal

When the service is running, go to the CRM settings page in the admin area: localhost:8075/config/master/crm

Perform authorization.

Last updated