microsoft / azure-gradle-plugins

Azure Plugins for Gradle
MIT License
45 stars 28 forks source link

When I cancel the `gradle azureFunctionsRun` command, gradle terminates, but `func` continues to run. #174

Open Miuler opened 1 year ago

Miuler commented 1 year ago

When I cancel the gradle azureFunctionsRun command, gradle terminates, but func continues to run, and the function continue running.

func -v
4.0.5413

build.gradle.kts

import com.microsoft.azure.gradle.configuration.GradleRuntimeConfig

group = "com.xxxxx"
version = "0.0.1-SNAPSHOT"

dependencyManagement {
    imports {
        mavenBom("org.springframework.boot:spring-boot-dependencies:3.1.3")
    }
}

dependencies {
    //implementation("org.projectlombok:lombok")
    implementation("ch.qos.logback:logback-classic")
    implementation("org.springframework.cloud:spring-cloud-function-adapter-azure:4.1.0-SNAPSHOT")
    implementation("com.azure:azure-ai-openai:1.0.0-beta.4")
    implementation("com.fasterxml.jackson.module:jackson-module-jsonSchema:2.15.3")
    implementation("com.fasterxml.jackson.module:jackson-modules-java8:2.15.3")
    implementation("io.github.cdimascio:dotenv-java:3.0.0")
    implementation("com.knuddels:jtokkit:0.6.1")
    implementation("org.scala-lang:scala3-library_3:3.3.1")

    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude(mapOf("group" to "org.junit.vintage", "module" to "junit-vintage-engine"))
    }
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")
    testImplementation("org.mockito:mockito-core:5.4.0")
    testImplementation("org.scalatestplus:junit-5-10_3:3.2.17.0")
    testImplementation("org.scalatest:scalatest_3:3.2.17")
}

plugins {
    id("idea")
    id("java")
    id("scala")
    id("io.freefair.lombok") version "8.4"
    id("org.springframework.boot") version "3.1.5"
    id("io.spring.dependency-management") version "1.0.11.RELEASE"
    id("com.microsoft.azure.azurefunctions") version "1.13.1"
    id("org.springframework.boot.experimental.thin-launcher") version "1.0.31.RELEASE"
}

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

springBoot {
    mainClass = "com.xxxxx.infrastructure.ApplicationMain"
    buildInfo {
        properties {
            additional.set(mapOf(
                    "java.version" to JavaLanguageVersion.of(17)
            ))
        }
    }
}

azurefunctions {
    appName = "xxxx"
    resourceGroup = "xxxxx"
    region = "eastus"
    pricingTier = "Consumption"

    setRuntime(closureOf<GradleRuntimeConfig> {
        os("Linux")
        javaVersion("17")
    })
    setAppSettings(closureOf<MutableMap<String, String>> {
        put("FUNCTIONS_EXTENSION_VERSION", "~4")
    })
    //setAuth(closureOf<GradleAuthConfig> { type = "azure_cli" })
    //localDebug = "transport=dt_socket,server=y,suspend=n,address=5005"
}

tasks.named<Test>("test") {
    useJUnitPlatform()
}

tasks.register<Copy>("copyEnv") {
    from(".env")
    into("build/azure-functions/xxxxx/")
}

tasks.getByName("build").dependsOn("copyEnv")

repositories {
    mavenCentral()
    maven { url = uri("https://repo.spring.io/libs-snapshot-local") }
    maven { url = uri("https://repo.spring.io/libs-milestone-local") }
    maven { url = uri("https://repo.spring.io/libs-release-local") }
    //maven { url = uri("https://repo.spring.io/release") }
}
Flanker32 commented 11 months ago

@Miuler Thanks for your report and sorry for the late response. We will investigate this issue soon, as a workaround, could you please try gradle --stop and see whether it helps for this issue?

CrawX commented 11 months ago

I'm having the same issue and am using this (somewhat hackish) workaround:

kill_running() {
  local pid
  pid="$(ps aux | grep -E "/azure-functions-core-tools.*/func host start" | grep -v grep | awk '{print $2}' || true)"
  if [[ -n "$pid" ]]; then
    echo "killing previous function run with pid $pid"
    kill -9 "$pid"
  fi
}
luisgoncalves commented 6 months ago

We will investigate this issue soon, as a workaround, could you please try gradle --stop and see whether it helps for this issue?

I'm also facing this issue. gradle --stop actually hangs. If I kill the func process on the side, then gradle --stop completes.

Any news on this?

Miuler commented 1 month ago

Any news on this topic?