go-graphite / go-carbon

Golang implementation of Graphite/Carbon server with classic architecture: Agent -> Cache -> Persister
MIT License
804 stars 123 forks source link

[Q]Flags do not work red hat 8 #558

Closed itinneed2022 closed 10 months ago

itinneed2022 commented 1 year ago

No matter how I try to run the tags, go-carbon runs in user mode. I've tried ./go-carbon -config /app/graphite/go-carbon/go-carbon.conf -daemon=false ./go-carbon -config /app/graphite/go-carbon/go-carbon.conf -daemon false ./go-carbon -config /app/graphite/go-carbon/go-carbon.conf -daemon=true ./go-carbon -config /app/graphite/go-carbon/go-carbon.conf -daemon=True

I've tried specifying a pid file, moving the -daemon flag in front of config, and each time it still runs interactively. How do I force it to run as a background daemon? I installed it using the readme's binary and make file.

deniszh commented 1 year ago

you don't need to provide any parameters to -daemon flag.

./go-carbon -config /app/graphite/go-carbon/go-carbon.conf

should run process in foreground.

./go-carbon -config /app/graphite/go-carbon/go-carbon.conf -daemon -pidfile /path/to/pidfile.pid

should run process in background.

itinneed2022 commented 1 year ago

I tried ./go-carbon -config /app/graphite/go-carbon/go-carbon.conf -daemon -pidfile /app/graphite/go-carbon/gocarbon.pid

It still runs interactively.

itinneed2022 commented 1 year ago

Anyone have an ideas? The logs in /var/log/go-carbon/go-carbon.log do not seem to even reference the startup of a -daemon attempt.

Has anyone successfully got this to run using systemd?

itinneed2022 commented 10 months ago

I tried using a systemd service script:

[Unit]
Description=Golang implementation of Graphite/Carbon server.
Documentation=https://github.com/go-graphite/go-carbon
After=network-online.target local-fs.target
Wants=network-online.target local-fs.target

[Service]
Type=forking
ExecStart=/app/graphite/go-carbon/go-carbon -config /app/graphite/go-carbon/go-carbon.conf -pidfile /var/run/go-carbon.pid -daemon
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=USR2
Restart=on-failure

TimeoutStopSec=600
LimitNOFILE=1048576
LimitMEMLOCK=infinity

[Install]
WantedBy=multi-user.target

However whenever I try to start it, I get:

● go-carbon.service - Golang implementation of Graphite/Carbon server.
   Loaded: loaded (/usr/lib/systemd/system/go-carbon.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2023-11-10 10:00:40 EST; 3s ago
     Docs: https://github.com/go-graphite/go-carbon
  Process: 162034 ExecStart=/app/graphite/go-carbon/go-carbon -config /app/graphite/go-carbon/go-carbon.conf -pidfile /var/run/go-carbon.pid -daemon (code=exited, status=0/SUCCESS)
 Main PID: 162040 (code=exited, status=1/FAILURE)

Nov 10 10:00:40 mygraphiteserver systemd[1]: go-carbon.service: Service RestartSec=100ms expired, scheduling restart.
Nov 10 10:00:40 mygraphiteserver systemd[1]: go-carbon.service: Scheduled restart job, restart counter is at 5.
Nov 10 10:00:40 mygraphiteserver systemd[1]: Stopped Golang implementation of Graphite/Carbon server..
Nov 10 10:00:40 mygraphiteserver systemd[1]: go-carbon.service: Start request repeated too quickly.
Nov 10 10:00:40 mygraphiteserver systemd[1]: go-carbon.service: Failed with result 'exit-code'.
Nov 10 10:00:40 mygraphiteserver systemd[1]: Failed to start Golang implementation of Graphite/Carbon server..

I already permitted go-carbon in selinux. The log file at /var/log/go-carbon/go-carbon.log is empty.

itinneed2022 commented 10 months ago

I just tried this on Fedora 37 and it seems to work. Either Red Hat 8 is to old for this to work or go1.19.10 linux/amd64 is to old?

deniszh commented 10 months ago

@itinneed2022 : I have no idea what's wrong with your RHEL8 installation but if you struggling with daemon mode just do no use it. Use following service script service:

...
[Service]
Type=simple
Restart=always
ExecStart=/app/graphite/go-carbon/go-carbon -config /etc/go-carbon.conf
ExecReload=/bin/kill -HUP $MAINPID
KillSignal=USR2

...
itinneed2022 commented 10 months ago

That seems to work. So its not golang, its entirely RHEL 8. I turned off selinux (didn't help), so I need to find some logs to figure out what's up with the pid and daemon flags. Thanks deniszh.