V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
imherer
V2EX  ›  Go 编程语言

systemctl 管理 go 进程问题

  •  
  •   imherer · 2019-04-03 17:38:26 +08:00 · 3192 次点击
    这是一个创建于 1847 天前的主题,其中的信息可能已经有所发展或是发生改变。

    初学 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 条回复    2019-04-03 22:43:03 +08:00
    cszhiyue
        1
    cszhiyue  
       2019-04-03 17:55:30 +08:00
    cszhiyue
        2
    cszhiyue  
       2019-04-03 17:57:50 +08:00   ❤️ 1
    另外建议用 sudo systemctl start wombatapp.service
    zarte
        3
    zarte  
       2019-04-03 17:59:23 +08:00
    直接后台运行呗。
    imherer
        4
    imherer  
    OP
       2019-04-03 18:01:23 +08:00
    @cszhiyue 感谢回复。 发现是权限问题…… sudo 就好了😂
    imherer
        5
    imherer  
    OP
       2019-04-03 18:02:20 +08:00
    @zarte 用个管理工具,万一程序因为某些原因挂了它能重启
    wdlth
        6
    wdlth  
       2019-04-03 22:43:03 +08:00
    Type 有很多种的,可以换其他的如 forking, notify 试试效果
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3349 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 00:39 · PVG 08:39 · LAX 17:39 · JFK 20:39
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.