dotnet core
我已經在Linux Arm機器上開發並發布了一個Web應用程式。為此,已啟動命令:
dotnet publish --runtime linux-arm -p:PublishSingleFile=true
結果給了目錄:
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 10/03/2020 8:56 wwwroot
-a---- 09/03/2020 10:54 162 appsettings.Development.json
-a---- 09/03/2020 10:54 192 appsettings.json
-a---- 10/03/2020 8:56 108097487 coremonitor
-a---- 09/03/2020 12:59 7248 coremonitor.pdb
-a---- 10/03/2020 8:56 474 web.config
coremonitor
可執行檔在哪裡。該數據被發送到伺服器並儲存在路徑中/root/datalogger/linux-arm/
。然後我們建立了 systemd 守護程式來啟動它:
[Unit]
Description=Data Logger Monitor Daemon
[Service]
ExecStart=./coremonitor
WorkingDirectory=/root/dataloggermonitor/linux-arm
User=dotnetuser
Group=dotnetuser
Restart=on-failure
SyslogIdentifier=DataLoggerMonitor-Service
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重新啟動後,我得到以下 systemd 日誌(systemctl status dataloggermonitor
):
● dataloggermonitor.service - Data Logger Monitor Daemon
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)
答案1
透過在參數中直接輸入執行路徑可以解決此問題ExecStart
。系統將從自己的相對路徑啟動可執行檔:
[Unit]
Description=Data Logger Monitor Daemon
[Service]
ExecStart=/root/dataloggermonitor/linux-arm/coremonitor
User=dotnetuser
Group=dotnetuser
Restart=on-failure
SyslogIdentifier=DataLoggerMonitor-Service
PrivateTmp=true
[Install]
WantedBy=multi-user.target
得到:
● dataloggermonitor.service - Data Logger Monitor Daemon
Loaded: loaded (/etc/systemd/system/dataloggermonitor.service; enabled)
Active: active (running) since Tue 2020-03-10 10:33:41 CET; 28s ago
Main PID: 403 (coremonitor)
CGroup: /system.slice/dataloggermonitor.service
└─403 /root/dataloggermonitor/linux-arm/coremonitor
Mar 10 10:33:41 techbase systemd[1]: Starting Data Logger Monitor Daemon...
Mar 10 10:33:41 techbase systemd[1]: Started Data Logger Monitor Daemon.
Mar 10 10:34:01 techbase DataLoggerMonitor-Service[403]: Hosting environment: Production
Mar 10 10:34:01 techbase DataLoggerMonitor-Service[403]: Content root path: /var/tmp/.net/coremonitor/gcrmbwbh.wxk/
Mar 10 10:34:01 techbase DataLoggerMonitor-Service[403]: Now listening on: http://[::]:5000
Mar 10 10:34:01 techbase DataLoggerMonitor-Service[403]: Application started. Press Ctrl+C to shut down.