Skip to content

Commit 53604f2

Browse files
committed
add auto-upgrade-toolsh usage doc
1 parent d495f25 commit 53604f2

File tree

1 file changed

+148
-2
lines changed

1 file changed

+148
-2
lines changed

docs/subquery_network/node_operators/setup/becoming-a-node-operator.md

Lines changed: 148 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Let's take an overview of the basic steps involved in the process:
1919
| [Step 7](#7-allocate-your-sqt-stake-to-start-receiving-rewards) | Allocate your SQT to start receiving rewards |
2020
| [Step 8](#8-troubleshooting-and-faqs) | Troubleshooting and FAQs |
2121
| [Step 9](#9-setting-up-a-grafana-dashboard-optional) | Optional: Setting up a Grafana Dashboard |
22-
| [Step 10](#10-upgrade-node-operator-services-ongoing) | Ongoing: Update Node Operator Services |
22+
| [Step 10](#10-cron-job-for-auto-upgrading-docker-compose) | Automate Docker Compose upgrades |
23+
| [Step 11](#11-upgrade-node-operator-services-ongoing) | Ongoing: Update Node Operator Services |
2324

2425
## 1. Deploy Node Operator Services
2526

@@ -204,7 +205,152 @@ Once you have successfully logged in, look for 'dashboards' on the left-hand sid
204205
![grafana_query_count](/assets/img/network/grafana_query_count.png)
205206
![grafana_query_stats](/assets/img/network/grafana_query_stats.png)
206207

207-
## 10. Upgrade Node Operator services (Ongoing)
208+
## 10. Cron Job for Auto-Upgrading Docker Compose
209+
210+
### Step 1: Download the `auto-upgrade-tool.sh` Script
211+
212+
Use the following command to download the `auto-upgrade-tool.sh` script:
213+
214+
```sh
215+
curl https://raw.githubusercontent.com/subquery/network-indexer-services/main/deploy/auto-upgrade-tool.sh -o auto-upgrade-tool.sh
216+
```
217+
218+
### Step 2: Basic Usage of `auto-upgrade-tool.sh`
219+
220+
The `auto-upgrade-tool.sh` script automatically fetches the latest tags for `subquerynetwork/indexer-coordinator` and `subquerynetwork/indexer-proxy` from Docker Hub and updates the versions in your Docker Compose configuration file.
221+
222+
```sh
223+
# Default usage with `docker-compose.yml`
224+
./auto-upgrade-tool.sh
225+
226+
# Specify a custom Docker Compose file
227+
./auto-upgrade-tool.sh -f my-compose.yml
228+
229+
# Force the script to run `docker compose up` without confirmation
230+
./auto-upgrade-tool.sh -u
231+
```
232+
233+
### Step 3: Sample Script Execution
234+
235+
Here’s an example of running the script:
236+
237+
```sh
238+
./auto-upgrade-tool.sh
239+
Latest coordinator tag: v2.10.0
240+
Latest proxy tag: v2.9.0
241+
📦 Backup created: docker-compose.yml.20250429_180911.bak
242+
✅ Coordinator tag updated to v2.10.0.
243+
🎉 docker-compose.yml has been updated to the latest tags.
244+
Do you want to run 'docker compose up'? (yes/[no]): yes
245+
🔄 Pulling latest images:
246+
Command : docker compose pull
247+
Config file: docker-compose.yml
248+
WARN[0000] /Users/a/company_info/network-indexer-services/deploy/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
249+
[+] Pulling 5/5
250+
✔ redis Pulled 4.6s
251+
✔ ipfs Pulled 2.9s
252+
✔ proxy Pulled 2.9s
253+
✔ coordinator Pulled 4.3s
254+
✔ postgres Pulled 4.2s
255+
🔄 Starting services:
256+
Command : docker compose up -d
257+
Config file: docker-compose.yml
258+
WARN[0000] /Users/a/company_info/network-indexer-services/deploy/docker-compose.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
259+
WARN[0000] A network with the name `indexer_services` exists but was not created for project "deploy".
260+
Set `external: true` to use an existing network.
261+
[+] Running 5/5
262+
✔ Container indexer_cache Started 0.4s
263+
✔ Container indexer_db Healthy 5.9s
264+
✔ Container indexer_ipfs Healthy 5.9s
265+
✔ Container indexer_coordinator Healthy 11.5s
266+
✔ Container indexer_proxy Started 11.6s
267+
```
268+
269+
### Step 4: Docker Compose File Update Example
270+
271+
After running the script, the `docker-compose.yml` file will be updated. Below is an example of the changes:
272+
273+
```diff
274+
# git diff docker-compose.yml
275+
276+
Δ deploy/docker-compose.yml
277+
─────────────────────────────────────────────────────────────────────────────────────────
278+
────────────────┐
279+
• 18: services: │
280+
────────────────┘
281+
18 ⋮ 18 │ retries: 5
282+
19 ⋮ 19 │
283+
20 ⋮ 20 │ coordinator:
284+
-21 ⋮ 21 │ image: subquerynetwork/indexer-coordinator:v2.9.1
285+
+21 ⋮ 21 │ image: subquerynetwork/indexer-coordinator:v2.10.0
286+
22 ⋮ 22 │ container_name: indexer_coordinator
287+
23 ⋮ 23 │ restart: always
288+
24 ⋮ 24 │ ports:
289+
```
290+
291+
### Step 5: Setting Up a Cron Job
292+
293+
To automate the script execution, set up a cron job. Below is an example of a cron job that runs the script every 6 hours:
294+
295+
```sh
296+
0 */6 * * * /path/to/auto-upgrade-tool.sh -f /path/to/docker-compose.yml >> /var/log/auto-upgrade-cron.log 2>&1
297+
```
298+
299+
This will log the output to `/var/log/auto-upgrade-cron.log` for future reference.
300+
301+
#### Adding the Cron Job with `sudo`
302+
303+
To add the cron job as a superuser, use the following command:
304+
305+
```sh
306+
sudo crontab -e
307+
```
308+
309+
This will open the cron editor for the root user. Add the following line to schedule the script:
310+
311+
```sh
312+
0 */6 * * * /path/to/auto-upgrade-tool.sh -f /path/to/docker-compose.yml >> /var/log/auto-upgrade-cron.log 2>&1
313+
```
314+
315+
Save and exit the editor to apply the changes.
316+
317+
To verify that the cron job has been added, run:
318+
319+
```sh
320+
sudo crontab -l
321+
```
322+
323+
This will list all cron jobs for the root user, including the one you just added.
324+
325+
#### Adding the Cron Job with `sudo` (Direct Command)
326+
327+
To add the cron job directly without opening the editor, use the following command:
328+
329+
```sh
330+
echo "0 */6 * * * /path/to/auto-upgrade-tool.sh -f /path/to/docker-compose.yml >> /var/log/auto-upgrade-cron.log 2>&1" | sudo crontab -
331+
```
332+
333+
This will overwrite the existing root user's crontab with the new entry. If you want to preserve existing cron jobs, first list them using:
334+
335+
```sh
336+
sudo crontab -l
337+
```
338+
339+
Then append the new entry like this:
340+
341+
```sh
342+
(sudo crontab -l; echo "0 */6 * * * /path/to/auto-upgrade-tool.sh -f /path/to/docker-compose.yml >> /var/log/auto-upgrade-cron.log 2>&1") | sudo crontab -
343+
```
344+
345+
To verify the cron job has been added, run:
346+
347+
```sh
348+
sudo crontab -l
349+
```
350+
351+
This will list all cron jobs for the root user, including the one you just added.
352+
353+
## 11. Upgrade Node Operator services (Ongoing)
208354

209355
To upgrade a Node Operator service, you will need to update the version of the image used in the docker-compose file. This can be done by updating the image field in the service definition to the new version you want to use.
210356

0 commit comments

Comments
 (0)