树莓派 or 香橙派 部署c# .net 并设置开机启动
树莓派 or 香橙派 部署.net 并设置开机启动
先登录微软官网下载sdk包
复制到树莓派 or 香橙派 上面 /usr/software(自建目录)
树莓派
下载的包 aspnetcore-runtime-6.0.8-linux-arm.tar.gz
执行指令
cd /usr/software sudo tar zxvf aspnetcore-runtime-6.0.8-linux-arm.tar.gz
香橙派
下载的包 aspnetcore-runtime-6.0.8-linux-arm64.tar.gz
执行指令
cd /usr/software sudo tar zxvf aspnetcore-runtime-6.0.8-linux-arm64.tar.gz
vi /etc/profile
在最后两行加上
export DOTNET_HOME=/usr/software export PATH=${DOTNET_HOME}:$PATH
reboot重启,输入指令查看是否安装成功
dotnet --info
上传.net程序部署后,设置开机启动
在本地pc电脑上先建好文件upgradeServer(服务名).service
文本方式打开,内容写入:
[Unit] Description="upgradeServer service" [Service] Type=simple GuessMainPID=true WorkingDirectory=/usr/net/upgradeServer(程序存放的目录) StandardOutput=journal StandardError=journal ExecStart=(dotnet sdk安装目录)/usr/software/dotnet upgradeServer.dll Restart=always [Install] WantedBy=multi-user.target
把文件
upgradeServer.service
通过ssh连接,xftp复制文件到树莓派 or 香橙派的系统目录下 /etc/systemd/system 即可
执 行命令启用
systemctl enable upgradeServer.service systemctl start upgradeServer.service
完美完成,重启测试一下
查看dotnet运行进程
ps -aux | grep "WebRoot.dll"
如图:
结束进程
kill 213498
