简介:它可以作为dotnet run
,但不能作为dotnet myappname.dll
。
我的Linux技能是有限的,但是我想按照本书学习,所以我不会混淆(遵循Scott Hanselman的本教程):
$ cd /home/myusername/dotnettest $ dotnet run
现在监听:http:// localhost:5123
然后像这样将其移动到/ var:
$ sudo cp -a /home/myusername/dotnettest/bin/Debug/netcoreapp1.1/publish /var/dotnettest
最后,我测试它是否也可以正常工作:
$ dotnet dotnettest.dll
然后失败:
info: Microsoft.Extensions.DependencyInjection.DataProtectionServices[0] User profile is available. Using '/home/myusername/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest. Unhandled Exception: System.AggregateException: One or more errors occurred. (Error -98 EADDRINUSE address already in use) ---> Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvException: Error -98 EADDRINUSE address already in use at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.Check(Int32 statusCode) at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.GetSockIPEndPoint() at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListener.CreateListenSocket() at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener.<>c.b__6_0(Object state) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer(ServerAddress address) at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application) at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start() at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage) at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host) at WebApplication.Program.Main(String[] args) in /home/myusername/dotnettest/Program.cs:line 27 Aborted (core dumped)
我在尝试停止nginx时非常小心。
我检查了是否有任何命令正在监听:5123:
$ lsof -i tcp:5123
而且似乎什么也没发生。
以下命令有助于找到端口并终止进程
Mac上的终端
查找过程号
lsof -i:
例如lsof -i:5001
然后杀死进程号
kill -9
例如-杀死-9 1600