mirror of
https://github.com/kerberos-io/agent.git
synced 2026-04-22 23:57:17 +08:00
Refactor build workflow to support multi-architecture builds and enhance MQTT connection handling
This commit is contained in:
@@ -7,61 +7,34 @@ env:
|
|||||||
REPO: kerberos/agent
|
REPO: kerberos/agent
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-amd64:
|
build:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ${{ matrix.runner }}
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
architecture: [amd64]
|
include:
|
||||||
|
- architecture: amd64
|
||||||
|
runner: ubuntu-24.04
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
- architecture: arm64
|
||||||
|
runner: ubuntu-24.04-arm
|
||||||
|
dockerfile: Dockerfile.arm64
|
||||||
steps:
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v2
|
uses: docker/login-action@v2
|
||||||
with:
|
with:
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- uses: benjlevesque/short-sha@v2.1
|
- uses: benjlevesque/short-sha@v2.1
|
||||||
id: short-sha
|
id: short-sha
|
||||||
with:
|
with:
|
||||||
length: 7
|
length: 7
|
||||||
- name: Run Build
|
- name: Run Build
|
||||||
run: |
|
run: |
|
||||||
docker build -t ${{matrix.architecture}} .
|
docker build -t ${{ matrix.architecture }} -f ${{ matrix.dockerfile }} .
|
||||||
CID=$(docker create ${{matrix.architecture}})
|
|
||||||
docker cp ${CID}:/home/agent ./output-${{matrix.architecture}}
|
|
||||||
docker rm ${CID}
|
|
||||||
- name: Strip binary
|
|
||||||
run: tar -cf agent-${{matrix.architecture}}.tar -C output-${{matrix.architecture}} . && rm -rf output-${{matrix.architecture}}
|
|
||||||
- name: Upload artifact
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: agent-${{matrix.architecture}}.tar
|
|
||||||
path: agent-${{matrix.architecture}}.tar
|
|
||||||
|
|
||||||
build-arm64:
|
|
||||||
runs-on: ubuntu-24.04-arm
|
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
architecture: [arm64]
|
|
||||||
steps:
|
|
||||||
- name: Login to DockerHub
|
|
||||||
uses: docker/login-action@v2
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKER_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- uses: benjlevesque/short-sha@v2.1
|
|
||||||
id: short-sha
|
|
||||||
with:
|
|
||||||
length: 7
|
|
||||||
- name: Run Build
|
|
||||||
run: |
|
|
||||||
docker build -t ${{matrix.architecture}} -f Dockerfile.arm64 .
|
|
||||||
CID=$(docker create ${{matrix.architecture}})
|
CID=$(docker create ${{matrix.architecture}})
|
||||||
docker cp ${CID}:/home/agent ./output-${{matrix.architecture}}
|
docker cp ${CID}:/home/agent ./output-${{matrix.architecture}}
|
||||||
docker rm ${CID}
|
docker rm ${CID}
|
||||||
|
|||||||
@@ -90,12 +90,16 @@ func ConfigureMQTT(configDirectory string, configuration *models.Configuration,
|
|||||||
|
|
||||||
// Some extra options to make sure the connection behaves
|
// Some extra options to make sure the connection behaves
|
||||||
// properly. More information here: github.com/eclipse/paho.mqtt.golang.
|
// properly. More information here: github.com/eclipse/paho.mqtt.golang.
|
||||||
opts.SetCleanSession(true)
|
opts.SetCleanSession(false)
|
||||||
|
opts.SetResumeSubs(true)
|
||||||
|
opts.SetStore(mqtt.NewMemoryStore())
|
||||||
opts.SetConnectRetry(true)
|
opts.SetConnectRetry(true)
|
||||||
opts.SetAutoReconnect(true)
|
opts.SetAutoReconnect(true)
|
||||||
opts.SetConnectRetryInterval(5 * time.Second)
|
opts.SetConnectRetryInterval(5 * time.Second)
|
||||||
|
opts.SetMaxReconnectInterval(1 * time.Minute)
|
||||||
opts.SetKeepAlive(30 * time.Second)
|
opts.SetKeepAlive(30 * time.Second)
|
||||||
opts.SetPingTimeout(10 * time.Second)
|
opts.SetPingTimeout(10 * time.Second)
|
||||||
|
opts.SetWriteTimeout(10 * time.Second)
|
||||||
opts.SetOrderMatters(false)
|
opts.SetOrderMatters(false)
|
||||||
opts.SetConnectTimeout(30 * time.Second)
|
opts.SetConnectTimeout(30 * time.Second)
|
||||||
opts.SetConnectionLostHandler(func(client mqtt.Client, err error) {
|
opts.SetConnectionLostHandler(func(client mqtt.Client, err error) {
|
||||||
@@ -108,6 +112,9 @@ func ConfigureMQTT(configDirectory string, configuration *models.Configuration,
|
|||||||
opts.SetReconnectingHandler(func(client mqtt.Client, options *mqtt.ClientOptions) {
|
opts.SetReconnectingHandler(func(client mqtt.Client, options *mqtt.ClientOptions) {
|
||||||
log.Log.Warning("routers.mqtt.main.ConfigureMQTT(): reconnecting to MQTT broker")
|
log.Log.Warning("routers.mqtt.main.ConfigureMQTT(): reconnecting to MQTT broker")
|
||||||
})
|
})
|
||||||
|
opts.SetOnConnectHandler(func(c mqtt.Client) {
|
||||||
|
log.Log.Info("routers.mqtt.main.ConfigureMQTT(): MQTT session is online")
|
||||||
|
})
|
||||||
|
|
||||||
hubKey := ""
|
hubKey := ""
|
||||||
// This is the old way ;)
|
// This is the old way ;)
|
||||||
@@ -150,6 +157,8 @@ func ConfigureMQTT(configDirectory string, configuration *models.Configuration,
|
|||||||
if token := mqc.Connect(); token.WaitTimeout(30 * time.Second) {
|
if token := mqc.Connect(); token.WaitTimeout(30 * time.Second) {
|
||||||
if token.Error() != nil {
|
if token.Error() != nil {
|
||||||
log.Log.Error("routers.mqtt.main.ConfigureMQTT(): unable to establish mqtt broker connection, error was: " + token.Error().Error())
|
log.Log.Error("routers.mqtt.main.ConfigureMQTT(): unable to establish mqtt broker connection, error was: " + token.Error().Error())
|
||||||
|
} else {
|
||||||
|
log.Log.Info("routers.mqtt.main.ConfigureMQTT(): initial MQTT connection established")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Log.Error("routers.mqtt.main.ConfigureMQTT(): timed out while establishing mqtt broker connection")
|
log.Log.Error("routers.mqtt.main.ConfigureMQTT(): timed out while establishing mqtt broker connection")
|
||||||
|
|||||||
@@ -41,16 +41,10 @@ class Dashboard extends React.Component {
|
|||||||
this.handleLiveviewLoad = this.handleLiveviewLoad.bind(this);
|
this.handleLiveviewLoad = this.handleLiveviewLoad.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleLiveviewLoad() {
|
|
||||||
this.setState({
|
|
||||||
liveviewLoaded: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const liveview = document.getElementsByClassName('videocard-video');
|
const liveview = document.getElementsByClassName('videocard-video');
|
||||||
if (liveview && liveview.length > 0) {
|
if (liveview && liveview.length > 0) {
|
||||||
this.liveviewElement = liveview[0];
|
[this.liveviewElement] = liveview;
|
||||||
this.liveviewElement.addEventListener('load', this.handleLiveviewLoad);
|
this.liveviewElement.addEventListener('load', this.handleLiveviewLoad);
|
||||||
}
|
}
|
||||||
this.initialiseLiveview();
|
this.initialiseLiveview();
|
||||||
@@ -77,6 +71,12 @@ class Dashboard extends React.Component {
|
|||||||
dispatchSend(message);
|
dispatchSend(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleLiveviewLoad() {
|
||||||
|
this.setState({
|
||||||
|
liveviewLoaded: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
handleClose() {
|
handleClose() {
|
||||||
this.setState({
|
this.setState({
|
||||||
open: false,
|
open: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user