Skip to content

Commit

Permalink
feat: 修复启动问题,github action
Browse files Browse the repository at this point in the history
  • Loading branch information
devil committed Aug 2, 2024
1 parent bbe511a commit c252eb2
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 66 deletions.
35 changes: 12 additions & 23 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,21 @@ name: Docker Compose Management

on:
push:
branches: [ "master" ] # 触发条件:推送到 main 分支
branches: [ "master" ] # 触发条件:推送到 master 分支
workflow_dispatch: # 手动触发工作流

jobs:
manage_containers:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker
uses: docker/setup-buildx-action@v2

- name: Set up Docker Compose
uses: docker/setup-buildx-action@v2

- name: Start environment services
run: |
docker-compose -f docker-compose.env.yml up -d
env:
COMPOSE_FILE: docker-compose.env.yml

- name: List Docker images
run: docker images
- name: List Container
run: docker ps -a
- name: List Running Container
run: docker ps
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: 检查仓库代码 👁︎
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: 仓库文件列表 📦
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
34 changes: 0 additions & 34 deletions .github/workflows/maven-publish.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.Resource;

@SpringBootApplication
@EnableCaching
@EnableScheduling
Expand All @@ -18,7 +20,6 @@
public class OlecodeCodeJudgeServiceApplication {

public static void main(String[] args) {
InitMq.doInit();
SpringApplication.run(OlecodeCodeJudgeServiceApplication.class, args);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
package com.ioomex.codeJuge.app.judge.rabbitmq;

import com.rabbitmq.client.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class InitMq {

@Value("${spring.rabbitmq.host:localhost}")
private String localAdr;


public static void doInit() {
@PostConstruct
public void doInit() {
try {
// 创建连接工厂
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
factory.setHost(localAdr);

// 创建连接
Connection connection = factory.newConnection();
Expand All @@ -35,8 +44,4 @@ public static void doInit() {
e.printStackTrace();
}
}

public static void main(String[] args) {
doInit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class MyMessageConsumer {

// 指定程序监听的消息队列和确认机制
@SneakyThrows
@RabbitListener(queues = "code queue", ackMode = "MANUAL")
@RabbitListener(queues = "code_queue", ackMode = "MANUAL")
public void receiveMessage(String message, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
log.info("receiveMessage message = {}", message);
log.info("receiveMessage message = {}", message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ spring:
host: rabbitmq # localhost 改为 rabbitmq
port: 5672
password: guest
username: guest
username: guest

0 comments on commit c252eb2

Please sign in to comment.