Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: install-agent.sh doesn't upgrade the agent, at least no change from hub. #469

Open
Oaklight opened this issue Jan 22, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@Oaklight
Copy link
Contributor

Description

daily update doesn't seem to work. Rerun the install-agent.sh script doesn't upgrade the agent. At least from the hub, it's still 0.8.0.
I have to uninstall the agent using the install-agent.sh then reinstall it.

Expected Behavior

update the agent without uninstall

Steps to Reproduce

  1. install an earlier version using script
  2. enable the daily update. Or rerun the install script
  3. check hub after a while, disable/resume the corresponding agent

OS / Architecture

debian 12.9 & ubuntu 24.04

Beszel version

0.9.1 script after china-mirror patch

Installation method

Binary

Configuration

no special setting. all done by install-agent.sh script

Hub Logs

Agent Logs

@Oaklight Oaklight added the bug Something isn't working label Jan 22, 2025
@Oaklight Oaklight changed the title [Bug]: [Bug]: install-agent.sh doesn't upgrade the agent, at least no change from hub. Jan 22, 2025
@henrygd
Copy link
Owner

henrygd commented Jan 22, 2025

If you use install-agent.sh to update, try restarting the service afterward:

sudo systemctl restart beszel-agent.service

The auto update may not work if your machine is in China because the built-in update (./beszel-agent update) does not use a proxy for GitHub.

I'm using rhysd/go-github-selfupdate which does not appear to support a proxy URL. I will look into forking adding support for this.

@Oaklight
Copy link
Contributor Author

I have machine both in and outside china. The autoupdate doesn't work on either machines.

@henrygd
Copy link
Owner

henrygd commented Jan 22, 2025

Okay, no worries. Let's figure this out.

What happens when you run these commands?

/opt/beszel-agent/beszel-agent -v
/bin/sh -c '/opt/beszel-agent/beszel-agent update | grep -q "Successfully updated" && (echo "Update found, restarting beszel-agent" && systemctl restart beszel-agent) || echo "No updates found"'
/opt/beszel-agent/beszel-agent -v

And can you please paste the content of /etc/systemd/system/beszel-agent-update.service?

@Oaklight
Copy link
Contributor Author

I run the three commands on the machine displayed as 0.8.0 from hub.

~# /opt/beszel-agent/beszel-agent -v
beszel-agent 0.9.1
~# /bin/sh -c '/opt/beszel-agent/beszel-agent update | grep -q "Successfully updated" && (echo "Update found, restarting beszel-agent" && systemctl restart beszel-agent) || echo "No updates found"'
No updates found
~# /opt/beszel-agent/beszel-agent -v
beszel-agent 0.9.1
~# systemctl ^C
~# sudo systemctl restart beszel-agent.service

and I restart the systemd service with sudo systemctl restart beszel-agent.service
then paused a while to check hub, 0.9.1 now.

# cat /etc/systemd/system/beszel-agent-update.service
[Unit]
Description=Update beszel-agent if needed
Wants=beszel-agent.service

[Service]
Type=oneshot
ExecStart=/bin/sh -c '/opt/beszel-agent/beszel-agent update | grep -q "Successfully updated" && (echo "Update found, restarting beszel-agent" && systemctl restart beszel-agent) || echo "No updates found"'

How to make the systemd service auto restart after the daily update?

@henrygd
Copy link
Owner

henrygd commented Jan 24, 2025

The auto update should restart the service if an update was found.

We can run a test. First download an older version of the agent (0.9.0) and move it to /opt/beszel-agent/

curl -sL "https://github.com/henrygd/beszel/releases/download/v0.9.0/beszel-agent_$(uname -s)_$(uname -m | sed -e 's/x86_64/amd64/' -e 's/armv6l/arm/' -e 's/armv7l/arm/' -e 's/aarch64/arm64/').tar.gz" | tar -xz -O beszel-agent | tee /tmp/beszel-agent >/dev/null && chmod +x /tmp/beszel-agent
sudo mv /tmp/beszel-agent /opt/beszel-agent/beszel-agent

Check that it is 0.9.0 and restart the agent.

/opt/beszel-agent/beszel-agent -v
sudo systemctl restart beszel-agent.service

If you pause and unpause in the hub, it should now show 0.9.0.

Next we will manually run the auto update job:

sudo systemctl start beszel-agent-update.service

If we check the service status we should see that it ran and updated the agent:

systemctl status beszel-agent-update.service
Jan 23 20:56:31 xxx systemd[1]: Starting Update beszel-agent if needed...
Jan 23 20:56:32 xxx sh[1001249]: Update found, restarting beszel-agent
Jan 23 20:56:32 xxx systemd[1]: beszel-agent-update.service: Deactivated successfully.
Jan 23 20:56:32 xxx systemd[1]: Finished Update beszel-agent if needed.

Checking the binary version again should show 0.9.1:

/opt/beszel-agent/beszel-agent -v

And the agent version should update in the hub by itself within one minute.

If you run this and see anything different then it may be a bug. Please let me know what happens. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants