【问题标题】:How to add environment variable 'DOTNET_CLI_HOME' to .Net Systemd service?如何将环境变量“DOTNET_CLI_HOME”添加到 .Net Systemd 服务?
【发布时间】:2020-05-27 09:05:22
【问题描述】:

我正在 VM 的 Ubuntu 18 中安装 Worker Service。当我使用以下命令时出现错误

sudo systemctl start myservice.service

错误:

 ● myservice.service - dummyservice in .NET Loaded: loaded
 (/lib/systemd/system/myservice.service; disabled; vendor preset:
 enabled) Active: failed (Result: exit-code) since Tue 2020-05-26
 23:53:20 IST; 10min ago Process: 3634 ExecStart=/usr/bin/dotnet
 /home/linux/bin/Downloads/myservice.dll (code=exited,
 status=1/FAILURE)

 May 26 23:53:19 arvind systemd[1]: Starting myservice in .NET... May
 26 23:53:20 arvind dotnet[3634]: The user's home directory could not
 be determined. Set the 'DOTNET_CLI_HOME' environment variable to spec
 May 26 23:53:20 arvind systemd[1]: myservice.service: Control process
 exited, code=exited status=1 May 26 23:53:20 arvind systemd[1]:
 myservice.service: Failed with result 'exit-code'. May 26 23:53:20
 arvind systemd[1]: Failed to start myservice in .NET.

这是我的 .service 文件

[Unit]
Description=my Service in .NET
# Requires=xyz.service
# After=xyz.service

[Service]
Type=forking
ExecStart=/usr/bin/dotnet  /home/linux/Downloads/myService.dll

[Install]
WantedBy=multi-user.target

我该如何解决这个问题?

【问题讨论】:

    标签: .net linux asp.net-core .net-core


    【解决方案1】:

    我已将DOTNET_CLI_HOME 添加到.service 文件中

    Environment=DOTNET_CLI_HOME=/temp
    

    现在该文件看起来像它

    [Unit]
    Description=my Service in .NET
    # Requires=xyz.service
    # After=xyz.service
    
    [Service]
    Type=simple
    ExecStart=/usr/bin/dotnet  /home/linux/Downloads/myService.dll
    Environment=DOTNET_CLI_HOME=/temp
    [Install]
    WantedBy=multi-user.target
    

    【讨论】:

    • 我想你的意思是/tmp/
    猜你喜欢
    • 1970-01-01
    • 2018-01-04
    • 1970-01-01
    • 2019-10-13
    • 2020-10-07
    • 1970-01-01
    • 2019-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多