Attempting to fix systemd activation with minimal changes (#1925)
This commit is contained in:
parent
be1605a8d5
commit
a247a3d8e6
|
|
@ -28,5 +28,4 @@ before_install:
|
|||
- if test "$TRAVIS_OS_NAME" == "osx"; then brew update; brew install openssl; ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/; ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/; fi
|
||||
script:
|
||||
- ./build.sh
|
||||
# Temporarily disabled systemd activation test: https://github.com/aspnet/KestrelHttpServer/issues/1912#issuecomment-311162419
|
||||
# - if test "$TRAVIS_OS_NAME" != "osx"; then bash test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/SystemdActivation/docker.sh; fi
|
||||
- if test "$TRAVIS_OS_NAME" != "osx"; then bash test/Microsoft.AspNetCore.Server.Kestrel.FunctionalTests/SystemdActivation/docker.sh; fi
|
||||
|
|
|
|||
|
|
@ -3,26 +3,34 @@ FROM microsoft/dotnet-nightly:2.0-runtime-deps
|
|||
# The "container" environment variable is read by systemd.
|
||||
ENV container=docker
|
||||
|
||||
# This is required by systemd and won't work without "dotnet run --privileged".
|
||||
VOLUME ["/sys/fs/cgroup"]
|
||||
# Install and configure systemd which requires dbus for graceful shutdown.
|
||||
RUN ["apt-get", "-o", "Acquire::Check-Valid-Until=false", "update"]
|
||||
RUN ["apt-get", "install", "-y", "--no-install-recommends", "systemd-sysv"]
|
||||
|
||||
# Set proper systemd default target.
|
||||
RUN ["systemctl", "set-default", "multi-user.target"]
|
||||
|
||||
# Remove non-vital systemd services.
|
||||
RUN ["find", "/etc/systemd/system", "/lib/systemd/system", \
|
||||
"-path", "*.wants/*", \
|
||||
"-not", "-name", "*systemd-journald*", \
|
||||
"-not", "-name", "*systemd-tmpfiles*", \
|
||||
"-not", "-name", "*systemd-user-sessions*", \
|
||||
"-delete"]
|
||||
|
||||
# Copy .NET installation.
|
||||
ADD .dotnet/ /usr/share/dotnet/
|
||||
RUN ["ln", "-s", "/usr/share/dotnet/dotnet", "/usr/bin/dotnet"]
|
||||
|
||||
# Create activate-kestrel.service to launch the "publish" app on new requests to 8080.
|
||||
EXPOSE 8080
|
||||
ADD .dotnet/ /usr/share/dotnet/
|
||||
ADD publish/ /publish/
|
||||
ADD activate-kestrel.socket /etc/systemd/system/activate-kestrel.socket
|
||||
ADD activate-kestrel.service /etc/systemd/system/activate-kestrel.service
|
||||
ADD activate-kestrel.socket /etc/systemd/system/activate-kestrel.socket
|
||||
|
||||
# Install and configure systemd which requires dbus for graceful shutdown.
|
||||
RUN ["apt-get", "-o", "Acquire::Check-Valid-Until=false", "update"]
|
||||
RUN ["apt-get", "install", "-y", "dbus"]
|
||||
RUN ["systemctl", "mask", "getty.target", "console-getty.service"]
|
||||
RUN ["cp", "/lib/systemd/system/dbus.service", "/etc/systemd/system/"]
|
||||
RUN ["sed", "-i", "s/OOMScoreAdjust=-900//", "/etc/systemd/system/dbus.service"]
|
||||
# Automatically start activate-kestrel.socket on boot.
|
||||
RUN ["systemctl", "enable", "activate-kestrel.socket"]
|
||||
|
||||
# Automatically start activate-kestrel.service on boot.
|
||||
RUN ["ln", "-s", "/usr/share/dotnet/dotnet", "/usr/bin/dotnet"]
|
||||
RUN ["ln", "-s", "/usr/lib/systemd/system/activate-kestrel.service", "/etc/systemd/system/multi-user.target.wants/activate-kestrel.service"]
|
||||
|
||||
# Launch systemd.
|
||||
CMD ["/sbin/init"]
|
||||
# Launch systemd, with workaround for docker/docker#27202, technique based on comments from docker/docker#9212.
|
||||
CMD ["/bin/bash", "-c", "exec /sbin/init --log-target=journal 3>&1"]
|
||||
STOPSIGNAL SIGRTMIN+3
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
[Unit]
|
||||
Description=Kestrel Activation
|
||||
PartOf=activate-kestrel.service
|
||||
|
||||
[Socket]
|
||||
ListenStream=8080
|
||||
NoDelay=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
|||
Loading…
Reference in New Issue