ytyou / ticktock

TickTockDB is an OpenTSDB-like time series database, with much better performance.
GNU General Public License v3.0
72 stars 8 forks source link

how to add ticktock to systemd #34

Closed mzy2240 closed 1 year ago

mzy2240 commented 1 year ago

I am trying to add ticktock to systemd so that it could auto-start on boot. The server seems to be running, but it does not respond to any connection. Here is the log from systemctl:

khadas@khadas-vim3:~$ sudo systemctl status ticktock
● ticktock.service - TickTock service
     Loaded: loaded (/etc/systemd/system/ticktock.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-01-22 20:41:58 CST; 3min 30s ago
   Main PID: 2174 (tt)
      Tasks: 26 (limit: 4203)
     Memory: 9.3M
        CPU: 2min 52.082s
     CGroup: /system.slice/ticktock.service
             └─2174 /home/khadas/ticktock/bin/tt -c /home/khadas/ticktock/conf/tt.conf

Jan 22 20:42:37 khadas-vim3 tt[2174]: /home/khadas/ticktock/bin/tt(+0x3ee08)[0xaaaaaf69ee08]
Jan 22 20:42:37 khadas-vim3 tt[2174]: /home/khadas/ticktock/bin/tt(+0x32238)[0xaaaaaf692238]
Jan 22 20:42:37 khadas-vim3 tt[2174]: /home/khadas/ticktock/bin/tt(+0x32608)[0xaaaaaf692608]
Jan 22 20:42:37 khadas-vim3 tt[2174]: /home/khadas/ticktock/bin/tt(+0x32edc)[0xaaaaaf692edc]
Jan 22 20:42:37 khadas-vim3 tt[2174]: /home/khadas/ticktock/bin/tt(+0x1d67c)[0xaaaaaf67d67c]
Jan 22 20:42:37 khadas-vim3 tt[2174]: /home/khadas/ticktock/bin/tt(+0x1de90)[0xaaaaaf67de90]
Jan 22 20:42:37 khadas-vim3 tt[2174]: /home/khadas/ticktock/bin/tt(+0x34130)[0xaaaaaf694130]
Jan 22 20:42:37 khadas-vim3 tt[2174]: /lib/aarch64-linux-gnu/libstdc++.so.6(+0xd31fc)[0xffffa56431fc]
Jan 22 20:42:37 khadas-vim3 tt[2174]: /lib/aarch64-linux-gnu/libc.so.6(+0x7d5c8)[0xffffa536d5c8]
Jan 22 20:42:37 khadas-vim3 tt[2174]: /lib/aarch64-linux-gnu/libc.so.6(+0xe5d1c)[0xffffa53d5d1c]

And this is the systemd config:

[Unit]
Description=TickTock service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=khadas
ExecStart=/home/khadas/ticktock/bin/tt -c /home/khadas/ticktock/conf/tt.conf

[Install]
WantedBy=multi-user.target

Any idea or example on this?

ylin30 commented 1 year ago

I will do:

  1. ps -ef | grep tt to make sure TT process is running;
  2. ./admin/ping.sh to make sure TT does respond. You should be able to see 'pong' immediately. If not, then either host or port is not specified correctly, or TT is stuck.
  3. Look at logs to see anything suspicious. You may also consider increasing log level to HTTP or DEBUG to get more details in logs. Please send us the log if you can't figure it out.
ylin30 commented 1 year ago

Have you ever manually tested /home/khadas/ticktock/bin/tt -c /home/khadas/ticktock/conf/tt.conf to make sure it works?

ytyou commented 1 year ago

I tried the exact systemd config as yours, with one exception. I removed the 'User=...' entry; that is, I run the service as root. Seems to work for me.

yongtao@tsdb-h:/opt/ticktock$ sudo systemctl status ticktock ● ticktock.service Loaded: loaded (/etc/systemd/system/ticktock.service; disabled; vendor preset: enabled) Active: active (running) since Sun 2023-01-22 23:21:40 PST; 5min ago Main PID: 26788 (tt) Tasks: 15 (limit: 4625) Memory: 1.0M CPU: 543ms CGroup: /system.slice/ticktock.service └─26788 /opt/ticktock/bin/tt -c /opt/ticktock/conf/tt.conf

Jan 22 23:21:40 tsdb-h systemd[1]: Started ticktock.service. Jan 22 23:21:40 tsdb-h tt[26788]: Writing to log file: /opt/ticktock/log/ticktock.log Jan 22 23:21:42 tsdb-h systemd[1]: /etc/systemd/system/ticktock.service:1: Unknown section 'Uint'. Ignoring. yongtao@tsdb-h:/opt/ticktock$ ./admin/ping.sh pong yongtao@tsdb-h:/opt/ticktock$