V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
imherer

systemctl 管理 go 进程问题

  •  
  •   imherer · Apr 3, 2019 · 3623 views
    This topic created in 2581 days ago, the information mentioned may be changed or developed.

    初学 go,在部署的时候遇到了点问题,请大佬看下

    参考 这篇文章 ,在/usr/lib/systemd/system在文件夹下创建wombatapp.service文件并写入内容,然后执行service wombatapp start 报错如下:

    Failed to start wombatapp.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
    See system logs and 'systemctl status wombatapp.service' for details
    

    执行 systemctl status wombatapp.service 结果

    ● wombatapp.service - wombatapp
       Loaded: loaded (/usr/lib/systemd/system/wombatapp.service; disabled; vendor preset: disabled)
       Active: inactive (dead)
    

    wombatapp.service 文件内容:

    [Unit]
    Description=wombatapp
    
    [Service]
    Type=simple
    Restart=always
    RestartSec=5s
    ExecStart=/home/ec2-user/wombatapp
    
    [Install]
    WantedBy=multi-user.target
    

    单独执行 wombatapp 文件是能成功运行的, 另外尝试了下用supervior来管理到是很轻松,没遇到任何问题直接成功了

    6 replies    2019-04-03 22:43:03 +08:00
    cszhiyue
        1
    cszhiyue  
       Apr 3, 2019
    cszhiyue
        2
    cszhiyue  
       Apr 3, 2019   ❤️ 1
    另外建议用 sudo systemctl start wombatapp.service
    zarte
        3
    zarte  
       Apr 3, 2019
    直接后台运行呗。
    imherer
        4
    imherer  
    OP
       Apr 3, 2019
    @cszhiyue 感谢回复。 发现是权限问题…… sudo 就好了😂
    imherer
        5
    imherer  
    OP
       Apr 3, 2019
    @zarte 用个管理工具,万一程序因为某些原因挂了它能重启
    wdlth
        6
    wdlth  
       Apr 3, 2019
    Type 有很多种的,可以换其他的如 forking, notify 试试效果
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3779 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 04:35 · PVG 12:35 · LAX 21:35 · JFK 00:35
    ♥ Do have faith in what you're doing.