Dotnet核心控制台应用程序作为debian上的守护进程

时间:2017-04-13 07:52:22

标签: linux shell debian .net-core daemon

我正在尝试将我的dotnet核心控制台应用程序作为debian OS上的守护程序运行,但似乎start-stop-daemon函数不会启动该进程。我无法弄清楚原因。

. /lib/lsb/init-functions

NAME=project-login
DESC="Project Login Server"
DAEMON=/usr/local/bin/dotnet
DAEMON_ARGS=/var/project/Project/src/Project.Login/bin/Debug/netcoreapp1.1/Project.Login.dll
PIDFILE=/var/run/$NAME.pid
PROJECT_BINARY=/var/project/Project/binary

do_start()
{
    start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON --test > /dev/null || return 1
    start-stop-daemon --chdir $PROJECT_BINARY --start --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON -- $DAEMON_ARGS || return 2
}

do_stop()
{
    echo "stop"
}

case "$1" in
    start)
        do_start
        ;;
    stop)
        do_stop
        ;;
    restart)
        do_stop
        do_start
        ;;
    *)
        echo "Usage: project-login [start|stop|restart]"
        exit 3
        ;;
esac
exit 0

我做完了:

$> systemctl daemon-reload
$> /etc/init.d/project-login start

当我启动该服务时,它会告诉我它已经启动,但在htop我看不到任何dotnet进程正在运行。我错过了什么或者我应该使用Docker而不是守护进程吗?

提前致谢

修改

Project.Login.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <AssemblyTitle>Project.Login</AssemblyTitle>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <AssemblyName>Project.Login</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>Project.Login</PackageId>
    <RuntimeIdentifiers>win10-x64;win7-x64;osx.10.10-x64;ubuntu.14.04-x64;ubuntu.14.10-x64;ubuntu.15.04-x64;ubuntu.15.10-x64;ubuntu.16.04-x64;ubuntu.16.10-x64;centos.7-x64;debian.8-x64;fedora.23-x64;fedora.24-x64</RuntimeIdentifiers>
    <!--<PackageTargetFallback>$(PackageTargetFallback);dnxcore50</PackageTargetFallback>
    <RuntimeFrameworkVersion>1.0.4</RuntimeFrameworkVersion>-->
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\Project.Core\Project.Core.csproj" />
    <ProjectReference Include="..\Project.Database\Project.Database.csproj" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Ether.Network" Version="1.1.7" />
  </ItemGroup>

</Project>

0 个答案:

没有答案