当前位置:   article > 正文

FastTunnel在Ubuntu上以服务方式部署并开机自启动(.NET Core)

FastTunnel在Ubuntu上以服务方式部署并开机自启动(.NET Core)

本博文的步骤是针对FastTunnel的server端,当然client端或其他基于.NET core的程序都可以参考

===================================
安装dotnet运行时:
-----------------------------------------------------------
添加如下deb(额外的,例如Ubuntu16.04需要设置):
wget https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
-----------------------------------------------------------

正常的:
sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0
sudo apt-get update && \
  sudo apt-get install -y aspnetcore-runtime-6.0
sudo apt-get install -y dotnet-runtime-6.0
-----------------------------------------------------------

压缩文件
tar -zxvf FastTunnel.Client.linux-x64.tar.gz
-----------------------------------------------------------

===================================
终端前台方式运行(关闭终端或SSH连接后会自动关闭该进程):
dotnet yourapplication.dll
----------------------------------------------------------
后台方式运行(关闭终端或SSH连接后会自动关闭该进程):
dotnet MyApp.dll &
-----------------------------------------------------------

===================================
服务方式运行:
-----------------------------------------------------------
编辑服务运行配置文件
sudo nano /etc/systemd/system/myapp.service
-----------------------------------------------------------
有效的配置
[Unit]
Description=My .NET Core Application
After=network.target

[Service]
User=root
WorkingDirectory=/root/FastTunnel.Server.linux-x64
ExecStart=/usr/bin/dotnet /root/FastTunnel.Server.linux-x64/FastTunnel.Server.dll
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=FastTunnel

[Install]
WantedBy=multi-user.target
-----------------------------------------------------------
生效和运行服务
sudo systemctl daemon-reload    # 重载Systemd配置
sudo systemctl enable myapp.service    # 设置服务为开机启动

sudo systemctl start myapp.service    # 启动服务
sudo systemctl status myapp.service    # 检查服务状态
-----------------------------------------------------------
检查日志
 journalctl -u fasttunnel.service -e
-----------------------------------------------------------

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/522552
推荐阅读
相关标签
  

闽ICP备14008679号