How to make the XMR run automaticaly

Hi,

Good day, how we can run continuously the XIBO automatically on our server? We are using digitalocean Ubuntu 16.04.4 x64 and XIBO 1.8.2 at the moment we run the XMR manually. Any idea or any solution aside on updating its Xibo core to its latest version.

Thank you
Mark

Here is how it is done with us:
Our user is display, you can replace paths with your own:

  1. Create file xmrrun.sh
    cat > /home/display/bin/xmrrun.sh

#!/bin/bash
sudo /usr/bin/php /home/display/web/domain/public_html/vendor/bin/xmr.phar

  1. Create service file
    cat > /etc/systemd/system/xmr.service

[Unit]
Description = making network connection up
After = network.target
[Service]
ExecStart = /home/display/bin/xmrrun.sh
[Install]
WantedBy = multi-user.target

  1. Enable service file

sudo systemctl daemon-reload
sudo systemctl start xmr
sudo systemctl stop xmr
sudo systemctl restart xmr
systemctl status xmr

Thank you [TUISTERa] checking on this :wink:

Hi TUISTERa, Thanks for your swift responds, we followed your procedure and entered the correct path. However I just got this error. Please see attached screenshot. Thanks for your great help.

I think its works now! I just set the permission of xmr.service to 644 and then on the ExecStart = /home/display/bin/xmrrun.sh , I change and added a /bin/bash

Final result

ExecStart =/bin/bash /home/display/bin/xmrrun.sh

Please see attached screenshot

This procedure works, the XMR run on our server 16h after we integrated this solution and until now. Thanks for the great help @TUISTERa

2 Likes

Here’s an easier way to run XMR as a systemd service on Ubuntu (18.04).

Copy the whole block into your terminal and it will create the xibo-xmr service. You might want to adjust some values before doing that. In the [Service] section, adjust User and Group the whatever your web server / php is also running as. Usually it’s the www-data user. ExecStart requires the correct paths to your php binaries and the xmr.phar file included in Xibo.

sudo cat <<EOF >>/etc/systemd/system/xibo-xmr.service
[Unit]
Description=Xibo XMR
After=network.target

[Service]
User=www-data
Group=www-data
ExecStart=/usr/bin/php /srv/www/xibo/vendor/bin/xmr.phar
Restart=always
KillMode=process

[Install]
WantedBy=multi-user.target
EOF

Reload the systemd manager, enable the service at startup and finally, start the xmr service.

sudo systemctl daemon-reload
sudo systemctl enable xibo-xmr.service
sudo systemctl start xibo-xmr.service

You can check the status if the xmr service is properly running. Set debug to false in your config.json for detailed output. Output example to verify that xmr is running and php is listening to the internal cms and public display port set in config.json.

$ sudo systemctl status xibo-xmr
â—Ź xibo-xmr.service - Xibo XMR
   Loaded: loaded (/etc/systemd/system/xibo-xmr.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-12-17 22:37:19 UTC; 3s ago
 Main PID: 22496 (php)
    Tasks: 3 (limit: 4915)
   CGroup: /system.slice/xibo-xmr.service
           └─22496 /usr/bin/php /srv/www/xibo/vendor/bin/xmr.phar

Dec 17 22:37:19 srv001 systemd[1]: Started Xibo XMR.

$ sudo lsof -i -P -n | grep 22496
php       22496        www-data   10u  IPv4 816472      0t0  TCP 127.0.0.1:50001 (LISTEN)
php       22496        www-data   12u  IPv4 816474      0t0  TCP 10.0.30.10:9505 (LISTEN)

Am interested in this. Am trying to get the maintenance job run on my server but it just not running. will this fix get my maintain jobs running?

A few extra notes about setting up XMR: in Ubuntu 18.04 you can install ZeroMQ from the default repos using the package name libzmq3-dev. PHP bindings can be build using PECL. Don’t forget to enable the modules afterwards. It’s quite easy actually, just run a few apt install and pecl install commands, and use your favorite text editor to edit the configurations (config.json and php.ini). See my previous post to run XMR as a service.

I suppose you’re not running the docker package of the Xibo CMS, and you have a manual installation running on your servers. That’s why you’re in this thread, to set up XMR running because in the docker package that’s already set up for you.

Along XMR you also need to set up XTR. See the docs about XTR. The maintenance script is run with XTR. Documentation about XTR is 100% usable with Ubuntu 18.04 and it includes all the instructions you need. But I’ll type it out for you here.

Notice that my XMR script is not only easier to set up, it also enables you to run it as a specific user. My webserver (nginx) and php-fpm are running as the www-data user (default). And so should XMR and XTR. This is the correct way to handle ownership and permissions. You don’t need to chmod anything to your Xibo CMS installation. If you need to, the ownership of the CMS files are not set up correctly or your services (web, php, XMR or XTR) are running as the wrong user.

So to continue, you can set up an crontab for the right user. XTR is nothing more than a scheduled task that executes a php script. In my case, php has to execute the script as the user www-data. Create a scheduled task for the user www-data. One way of doing this is to use the crontab command.

crontab -u www-data -e

Select your favorite editor to edit the crontab for user www-data and append the following line.

* * * * * /usr/bin/php /var/www/xibo/bin/xtr.php

XTR is now set up and your maintenance script will run automatically.

Thank you i will try i provide feedback.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.