Asp.net core running on OpenWrt router

Currently only supports OpenWrt x86_64, you can only run on the soft route. And so after Microsoft released .NET Core musl binary ARM / ARM64 can run on an ordinary home router (as long as the memory is large enough)

Installation depends on the router 

root@OpenWrt:/# opkg install lttng-ust libopenssl libstdcpp zlib libintl-full

Need to add parameters -r linux-musl-x64 project is published  

dotnet publish -c Release -f netcoreapp2.1 -r linux-musl-x64

The resulting file bin \ Release \ \ \ publish copy all netcoreapp2.1 linux-musl-x64 to the router
to perform the test

root@OpenWrt:/# /mnt/sdb1/publish/myWebApp --urls http://0.0.0.0:81

Add startup items:
write an rc script /etc/init.d/aspdotnet 

#!/bin/sh /etc/rc.common
USE_PROCD=1
START=99
STOP=10

start_service() {
  procd_open_instance
  procd_set_param command /mnt/sdb1/publish/myWebApp --urls http://0.0.0.0:81

  procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
  procd_set_param limits core="unlimited"
  procd_set_param stdout 1
  procd_set_param stderr 1
  procd_close_instance
}

Given executable permissions 

root@OpenWrt:/# chmod +x /etc/init.d/aspdotnet

Enable the service, run the service

root@OpenWrt:/# /etc/init.d/aspdotnet enable
root@OpenWrt:/# /etc/init.d/aspdotnet start

Then you can visit http: // router address: 81 / visit 

Guess you like

Origin www.cnblogs.com/redpod/p/dotnet_core_openwrt.html