Views: 3893
Last Modified: 22.03.2021
The setup:
----------------------- ---------------------------------------------------
| nginx: 0.0.0.0:80 | -> /bitrix/sub|/bitrix/subws -> | node server.js --config push-server-sub-80XX.json |
----------------------- ---------------------------------------------------
----------------------- ---------------------------------------------------
| nginx: 127.0.0.1:8895 | -> /bitrix/pub -> | node server.js --config push-server-pub-90XX.json |
----------------------- ---------------------------------------------------
Nginx proxies query to push service of selected type. Message getting queries (for example, sub) are public and proxied from standard ports 80/443. Publication queries (pub) are available only from internal server address.
Nodejs processes are split into two types:
- Processes responsible for connecting user to selected channel and message reception. Listen to ports: 8010-8015;
- Processes responsible for sending message to channel. Listen to ports: 9010-9011.
To start Push-server we need:
- nodejs & npm ;
- service and its modules archive.
For installation we require Python or a make utility:
zypper install python3 make wget -y
Execute the following actions:
- Download and install archive push-server-0.2.2.tgz:
su -
cd /opt
wget https://repos.1c-bitrix.ru/vm/push-server-0.2.2.tgz
npm install --production ./push-server-0.2.2.tgz
Installation will finish with string:
+ push-server@0.2.2
added 65 packages in 46.522s
- Execute (exclusively for convenience):
su -
ln -sf /opt/node_modules/push-server/logs /var/log/push-server
ln -sf /opt/node_modules/push-server/etc/push-server /etc/push-server
- Copy service files and the main configuration:
su -
cd /opt/node_modules/push-server
cp etc/init.d/push-server-multi /usr/local/bin/push-server-multi
cp etc/sysconfig/push-server-multi /etc/sysconfig/push-server-multi
cp etc/push-server/push-server.service /etc/systemd/system/
ln -sf /opt/node_modules/push-server /opt/push-server
- Create temporary directory:
echo 'd /tmp/push-server 0770 apache apache -' > /etc/tmpfiles.d/push-server.conf
systemd-tmpfiles --remove --create
Edit config file /etc/sysconfig/push-server-multi
. The following parameters must be corrected/added:
- SECURITY_KEY - secret key for connection signature between customers and push server;
Note: Key length doesn't matter. The key can use only Latin letter and numbers, special characters are prohibited. But, be advised, that a too short of a key is unsafe. It can be generated as follows:
cat /dev/urandom |tr -dc A-Za-z0-9 | head -c 128
- RUN_DIR - director for process PID file storage.
- USER/GROUP - user that launched the service.
Example of parameter settings:
GROUP=apache
SECURITY_KEY="SECURITYKEY123456"
RUN_DIR=/tmp/push-server
- Each nodejs process is launched as separate process. Generate the configs:
/usr/local/bin/push-server-multi configs pub
/usr/local/bin/push-server-multi configs sub
Generated configs in the format
json
push-server-sub-80XX.json
push-server-pub-90XX.json
will be located in this directory: /etc/push-server/
.
- Update the user and path to script in the service config file
/etc/systemd/system/push-server.service
:
[Service]
User=apache
Group=apache
ExecStart=/usr/local/bin/push-server-multi systemd_start
...
- Update access permissions for directory with logs:
chown wwwrun:www /opt/node_modules/push-server/logs /tmp/push-server -RH
- Reconfigure:
systemctl daemon-reload
- Start the service:
systemctl --now enable push-server
- Go to push module config (site settings) and enable local push server (latest version).
Additionally, indicate SECURITY_KEY parameter, configured previously above in the file
/etc/sysconfig/push-server-multi
.