Linux 下随机启动 自己的应用 -请使用while(true) 不要Console.ReadKey()
开机启动脚本启动,某些程序无法启动 原因
例如写了一个服务,不能停止程序运行,所以主线程成不能退出
常规写法 while(true) //可以使用开关变量
{
Thread.Sleep(300);
}
 
在程序最后使用Console.ReadKey();来控制程序执行完不退出。Linux下开机启动失败
使用while true 代替即可
要达到Linux系统启动后就启动该程序
我写好了脚本
#!/bin/sh
#chkconfig: 2345 80 90
#descriptiong:auto HFService
cd /goldendsp/RoleMenuService/app
setsid mono HFService.exe
 
重启系统测试
ps -aux 查看线程 没有 mono HFService.exe 线程
最后使用while(true) 代替 Console.ReadKey();
搞定

相关文章:

  • 2021-12-15
  • 2021-11-20
  • 2021-05-25
  • 2021-11-16
  • 2021-11-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-31
  • 2021-11-22
  • 2021-11-20
  • 2021-06-24
  • 2021-09-12
  • 2022-01-18
相关资源
相似解决方案