Giter Site home page Giter Site logo

Comments (18)

pan-wang avatar pan-wang commented on May 17, 2024 5

ServiceMonitor stops w3svc service first to update applicationhost config with the environmental variables first and then restart the service. When container starts, it also starts the all services. There could be a timing issue that entry program (stopping service) was executed before Service started. To work around it, you can reset w3svc start type to manual in docker file, i.e., sc config w3svc start=demand. This will even save container start time.

from iis.servicemonitor.

DanOrsborne avatar DanOrsborne commented on May 17, 2024 1

Ok, I corrected the service name - my hurried mistake. This works thanks so much for the help! Code below to help the next person
Docker file:

FROM mcr.microsoft.com/dotnet/framework/aspnet:4.7.2-windowsservercore-ltsc2019 AS base
WORKDIR /inetpub/wwwroot
EXPOSE 80

FROM mcr.microsoft.com/dotnet/framework/sdk:4.7.2-windowsservercore-ltsc2019 AS build
WORKDIR /app

COPY . .
RUN nuget restore ./Website.csproj -SolutionDirectory ./..

RUN msbuild ./Website.csproj /p:Configuration=Release /p:DebugSymbols=false /p:DebugType=None /p:DeployOnBuild=true /p:PublishProfile=FolderProfile.pubxml

FROM base as runtime
ARG source
COPY --from=build /app/bin/Release/Publish/. ./

RUN powershell -Command Set-Service -Name w3svc -StartupType 'Manual'

COPY docker-entrypoint.ps1 /
ENTRYPOINT powershell -File C:\docker-entrypoint.ps1

Entry Point.ps1

Set-ItemProperty
Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters -Name AllowRemoteConnection -Value 1
Get-Service aspnet_state | Start-Service

C:\ServiceMonitor.exe w3svc

from iis.servicemonitor.

MikeChristensen avatar MikeChristensen commented on May 17, 2024

Perhaps helpful: This seems to occur when you modify the contents of web.config right before you call ServiceMonitor.exe. It might be some race condition since it doesn't always happen.

from iis.servicemonitor.

MikeChristensen avatar MikeChristensen commented on May 17, 2024

If I tail the logs in Docker, here's what I see:

image

So basically we transform some web.config, which causes the app pool to recycle. We then start ServiceMonitor.exe, which can't query the status of w3svc and immediately exits, causing the container the exit. This creates an endless loop in Service Fabric, since it then tries to restart the container again.

Expected: ServiceMonitor.exe should handle recycling app pools correctly.

from iis.servicemonitor.

MikeChristensen avatar MikeChristensen commented on May 17, 2024

Another annoying thing is when ServiceMonitor.exe exits with this error, it still returns an EXIT code of 0 so we can't trap the error and retry with a script.

Expected: $LASTEXITCODE should non-zero when the program exits with an error.

from iis.servicemonitor.

bariscaglar avatar bariscaglar commented on May 17, 2024

@MikeChristensen We'll look into this. Thanks for reporting. You can expect a response soon.

from iis.servicemonitor.

MikeChristensen avatar MikeChristensen commented on May 17, 2024

I've confirmed this workaround solves the issue. Basically, set the startup behavior to demand in the dockerfile, and set the entrypoint to transform the config files then run ServiceMonitor.exe (which will also start the service).

from iis.servicemonitor.

DanOrsborne avatar DanOrsborne commented on May 17, 2024

what does this actually mean?

Basically, set the startup behavior to demand in the dockerfile, and set the entrypoint to transform the config files then run ServiceMonitor.exe

What do we have to do to fix the issue?

from iis.servicemonitor.

jhkimnew avatar jhkimnew commented on May 17, 2024

The first set means to add "RUN sc config w3svc start=demand" as the below example dockerfile and the second one to replace the last line ("ENTRYPOINT ["C:\ServiceMonitor.exe", "w3svc"]) with calling your own batch file which does the configuration job and put "c:\servicemonitor w3svc" at the end of the batch file.

FROM mcr.microsoft.com/windows/servercore/iis:latest

RUN powershell -Command Add-WindowsFeature Web-Server
RUN sc config w3svc start=demand
EXPOSE 80
ENTRYPOINT ["C:\\ServiceMonitor.exe", "w3svc"]

from iis.servicemonitor.

DanOrsborne avatar DanOrsborne commented on May 17, 2024

That's perfect! Thanks for the example

from iis.servicemonitor.

DanOrsborne avatar DanOrsborne commented on May 17, 2024

I'm getting the following error with this example:
A positional parameter cannot be found that accepts argument

Any ideas?

from iis.servicemonitor.

DanOrsborne avatar DanOrsborne commented on May 17, 2024

Fixed the postional parameter issue with the following:
RUN powershell -Command Set-Service -Name aspnet_state -StartupType 'Manual'

from iis.servicemonitor.

DanOrsborne avatar DanOrsborne commented on May 17, 2024

However I still have the ServiceMonitor issue - it keeps preventing a container starting and then just randomly recycles several times. I have other containers with the same setup that work fine for a bit and then will crash with the same error later down the line.

Someone suggested updating Service Monitor but again gave no instructions

from iis.servicemonitor.

pan-wang avatar pan-wang commented on May 17, 2024

Do you have the docker log for the error case?

from iis.servicemonitor.

DanOrsborne avatar DanOrsborne commented on May 17, 2024

Task Log: ERROR: Failed to stop or query status of service 'w3svc' error [800705b4]

from iis.servicemonitor.

jhkimnew avatar jhkimnew commented on May 17, 2024

I think you used the wrong service name (aspnet_state). The right service name is w3svc as the following:

RUN powershell -Command Set-Service -Name w3svc -StartupType 'Manual'

from iis.servicemonitor.

pan-wang avatar pan-wang commented on May 17, 2024

800705b4 means timeout. It seams ServiceMonitor had trouble to access W3SVC service. Did you set W3SVC service to manual start mode in docker file? you said you had the same setup work fine for a bit and then will crash later, could you please give more details? Could you please check whether your container image is compatible with the host OS?

from iis.servicemonitor.

pan-wang avatar pan-wang commented on May 17, 2024

I assume you tried to build you project and publish it inside container to IIS and then access app. Could you please check whether the build succeeded and content was dropped correctly? Could you please share docker-entrypoint.ps1 so that we can make sure ServiceMonitor is in the picture? If possible, please open another issue as your problem seems not related with ServiceMonitor itself.

from iis.servicemonitor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.