• linux上以服务方式启动程序kestrel


    在linux上裸奔kestrel时,遇到一个问题.

    远程连接到linux,启动kestrel服务器,退出远程后,这个kestrel也关闭了

    这时,要以服务的方式启动程序

    实验环境:

    ubuntu 20.04 LTS

    systemd

    具体是使用systemd这个linux系统管理工具实现的.

    systemd介绍文档 http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html

    示例文档: https://www.raspberrypi.org/documentation/linux/usage/systemd.md

    配置文件字段解说: https://www.freedesktop.org/software/systemd/man/systemd.unit.html

    总的来说,就是给程序加个配置文件,就可以用systemctl start 服务名字 这个命令以服务方式启动程序.

    配置文件可以如下

    [Unit]
    Description=my httpserver
    
    [Service]
    ExecStart=/home/myhttp/myhttpserver.exe

    注意: = 两边不要空格(我没有验证)

    黄色部分是自己填写的,Description是程序说明,ExecStart这个就是程序的启动路径

    配置文件好了以后,取一个名字: myhttpserver.service,放到这个目录

    /usr/lib/systemd/system

    配置文件的名字就是服务名字,.service扩展命是固定的(我没有验证)

    最后,使用命令启动程序

    systemctl start myhttpserver

     
  • 相关阅读:
    C 应用
    C 基本语法
    iOS
    iOS
    iOS
    iOS
    iOS
    iOS
    iOS
    iOS
  • 原文地址:https://www.cnblogs.com/mirrortom/p/13836121.html
Copyright © 2020-2023  润新知