Skip to content

Commit 986ea17

Browse files
authored
Merge pull request #421 from ByteInternet/how-to-install-and-configure-mercure-on-hypernode
Add article "How to install and configure Mercure on Hypernode"
2 parents 5c0adce + 1705121 commit 986ea17

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
myst:
3+
html_meta:
4+
description: Mercure is a real-time communication protocol that enables server-sent
5+
events (SSE) for live updates in web applications. Learn how to install and
6+
configure Mercure on your Hypernode.
7+
title: How to install and configure Mercure on Hypernode?
8+
---
9+
10+
# How to install and configure Mercure on Hypernode
11+
12+
Mercure is a real-time communication protocol that enables server-sent events (SSE) for live updates in web applications. It's particularly useful for applications that need real-time notifications, live chat, or dynamic content updates.
13+
14+
In this guide, we'll walk you through installing and configuring Mercure on your Hypernode using Supervisor to ensure it runs reliably as a background service. This may be required for Pimcore in the future.
15+
16+
```{warning}
17+
Hypernode Support can't help or support this service on your Hypernode.
18+
```
19+
20+
## Installing Mercure
21+
22+
### Step 1: Download the Mercure binary
23+
24+
First, navigate to the [Mercure releases page](https://github.com/dunglas/mercure/releases) and find the most recent legacy Linux x86_64 tar.gz file. For this example, we'll use version 0.20.2:
25+
26+
```console
27+
app@abc-example-magweb-cmbl:~$ mkdir ~/mercure
28+
app@abc-example-magweb-cmbl:~$ cd ~/mercure
29+
app@abc-example-magweb-cmbl:~$ wget https://github.com/dunglas/mercure/releases/download/v0.20.2/mercure-legacy_Linux_x86_64.tar.gz
30+
app@abc-example-magweb-cmbl:~$ tar -xvzf mercure-legacy_Linux_x86_64.tar.gz
31+
app@abc-example-magweb-cmbl:~$ rm mercure-legacy_Linux_x86_64.tar.gz
32+
```
33+
34+
This will extract the `mercure` binary to your `~/mercure` directory.
35+
36+
### Step 2: Generate JWT keys
37+
38+
Mercure uses JWT (JSON Web Tokens) for authorization. You'll need to generate a secret key for signing JWTs. You can generate a secure random key using:
39+
40+
```console
41+
app@abc-example-magweb-cmbl:~$ openssl rand -base64 32
42+
```
43+
44+
Save this key securely - you'll need it for both the Mercure server configuration and your application's JWT generation.
45+
46+
## Configuring Mercure with Supervisor
47+
48+
### Step 3: Create Supervisor configuration
49+
50+
Create a Supervisor configuration file for Mercure. This ensures Mercure runs as a background service and automatically restarts if it crashes:
51+
52+
```console
53+
app@abc-example-magweb-cmbl:~$ mkdir -p ~/supervisor
54+
app@abc-example-magweb-cmbl:~$ nano ~/supervisor/mercure.conf
55+
```
56+
57+
Add the following configuration to the file:
58+
59+
```ini
60+
[program:mercure]
61+
command=/data/web/mercure/mercure run -jwt-key=your-jwt-key --addr :8001
62+
directory=/data/web/mercure
63+
autostart=true
64+
autorestart=true
65+
stderr_logfile=/data/web/supervisor/mercure.err.log
66+
stdout_logfile=/data/web/supervisor/mercure.out.log
67+
user=app
68+
```
69+
70+
**Important**: Replace `your-jwt-key` with the actual JWT secret key you generated in Step 2.
71+
72+
### Step 4: Enable Supervisor (if not already enabled)
73+
74+
If Supervisor isn't already enabled on your Hypernode, enable it:
75+
76+
```console
77+
app@abc-example-magweb-cmbl:~$ hypernode-systemctl settings supervisor_enabled true
78+
app@abc-example-magweb-cmbl:~$ livelog
79+
```
80+
81+
Wait for the changes to be applied before proceeding.
82+
83+
### Step 5: Start Mercure
84+
85+
Now reload Supervisor and start the Mercure service:
86+
87+
```console
88+
app@abc-example-magweb-cmbl:~$ supervisorctl reread
89+
mercure: available
90+
app@abc-example-magweb-cmbl:~$ supervisorctl update
91+
mercure: added process group
92+
app@abc-example-magweb-cmbl:~$ supervisorctl start mercure
93+
```
94+
95+
### Step 6: Verify Mercure is running
96+
97+
Check that Mercure is running correctly:
98+
99+
```console
100+
app@abc-example-magweb-cmbl:~$ supervisorctl status
101+
mercure RUNNING pid 12345, uptime 0:00:05
102+
app@abc-example-magweb-cmbl:~$ curl http://localhost:8001/.well-known/mercure
103+
```
104+
105+
If Mercure is working correctly, you should see a response indicating the Mercure hub is available.

0 commit comments

Comments
 (0)