Comments (18)
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.
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 80FROM mcr.microsoft.com/dotnet/framework/sdk:4.7.2-windowsservercore-ltsc2019 AS build
WORKDIR /appCOPY . .
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-ServiceC:\ServiceMonitor.exe w3svc
from iis.servicemonitor.
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.
If I tail the logs in Docker, here's what I see:
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.
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.
@MikeChristensen We'll look into this. Thanks for reporting. You can expect a response soon.
from iis.servicemonitor.
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.
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.
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.
That's perfect! Thanks for the example
from iis.servicemonitor.
I'm getting the following error with this example:
A positional parameter cannot be found that accepts argument
Any ideas?
from iis.servicemonitor.
Fixed the postional parameter issue with the following:
RUN powershell -Command Set-Service -Name aspnet_state -StartupType 'Manual'
from iis.servicemonitor.
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.
Do you have the docker log for the error case?
from iis.servicemonitor.
Task Log: ERROR: Failed to stop or query status of service 'w3svc' error [800705b4]
from iis.servicemonitor.
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.
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.
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)
- ServiceMonitor returns an error for Task Scheduler service HOT 1
- Make environment variables optional
- Show [Entrypoint ... ] syntax on the readme HOT 2
- Handle environment variable with single HOT 1
- Use ServiceMonitor for classic windows Services
- Implement a seperate function to handle special characters for AppCmd HOT 2
- Redirect specified log file to output HOT 2
- W3SVC getting stopped and not starting in docker container error [80070308] HOT 2
- Docker Images that use ServiceMonitor fail when using gmsa account on docker run
- Environment variable with %18 in the value breaks appcmd HOT 1
- Empty environment variables causes APPCMD to fail HOT 1
- Environment variables are not set HOT 1
- 4.8-20201013-windowsservercore-1909 image doesn't start HOT 2
- Many environment variables lead to `APPCMD failed with error code 259` error HOT 4
- Non-root user not able to start w3svc service in docker
- Intermittent errors with HRESULT8007045b
- ServiceMonitor do not support multiple application pools
- This repo is missing important files HOT 2
- Feature request: Add support for /? and dump version
- Facing intermittent issues in windows container during startup HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iis.servicemonitor.