ETCD logging question

463 views
Skip to first unread message

Francisco Andrade

unread,
Dec 6, 2017, 10:41:00 AM12/6/17
to etcd-dev
Hi guys, 

I'm testing ETCD but I'm having some hard time trying to store the ETCD logs in a file.
The problem happens when I try to execute ETCD in the background inside of a shell script.

Here is my etcd startup script:
#!/bin/bash

IP_ADDRESS=`/usr/bin/hostname -I | sed "s/ //g"`
: "${HOST_NAME:=${IP_ADDRESS}}"
ETCD_LOG_FILE=/var/log/etcd.log

export ETCD_LISTEN_CLIENT_URLS=http://${IP_ADDRESS}:2379,http://127.0.0.1:2379
export ETCD_LISTEN_PEER_URLS=http://${IP_ADDRESS}:2380
export ETCD_INITIAL_ADVERTISE_PEER_URLS=http://${IP_ADDRESS}:2380
export ETCD_ADVERTISE_CLIENT_URLS=http://${IP_ADDRESS}:2379
export ETCD_INITIAL_CLUSTER_TOKEN=test
export ETCD_INITIAL_CLUSTER_STATE=new
export ETCD_AUTO_COMPACTION_RETENTION=1
export ETCD_INITIAL_CLUSTER=${HOST_NAME}=http://${IP_ADDRESS}:2380

cd /opt/etcd
# TO DO: add logging
/usr/bin/nohup echo "Starting ETCD" >> $ETCD_LOG_FILE 2>&1 &
/usr/bin/nohup /opt/etcd/bin/etcd --name $HOST_NAME --data-dir /opt/etcd/data >> $ETCD_LOG_FILE 2>&1 &

ETCD starts as it should but I can't see any etcd log message on the $ETCD_LOG_FILE. 
I can see only "Starting ETCD" but not the etcd log lines.

When I run the last line manually from outside the script (after setting the vars) everything works fine. I can see all the logs on the file.
Here is the command:
/usr/bin/nohup /opt/etcd/bin/etcd --name $HOST_NAME --data-dir /opt/etcd/data >> $ETCD_LOG_FILE 2>&1 &

Can someone give me a hint of what is the problem, please?

Thanks,
Francisco Andrade

Francisco Andrade

unread,
Dec 6, 2017, 11:00:55 AM12/6/17
to etcd-dev
Just adding some more details, if I change the script to execute the commands without appending to a specific file, the nohup.out file is created, but have the same behaviour when appending to file.

I replace the last two lines for the following ones:
/usr/bin/nohup echo "Starting ETCD" &
/usr/bin/nohup /opt/etcd/bin/etcd --name $HOST_NAME --data-dir /opt/etcd/data &

Still, the only thing I see at the nohup.out file is the "Starting ETCD" line.
ETCD is running fine, although.

Thanks,
Francisco Andrade

Francisco Andrade

unread,
Dec 6, 2017, 11:20:19 AM12/6/17
to etcd-dev
Just one more detail, when I remove the & from the last line and run etcd in the foreground, the log works fine. Either appending to nohup.out or other specific files.

Francisco Andrade

unread,
Dec 6, 2017, 11:22:51 AM12/6/17
to etcd-dev
Environement details:
CentOS Linux release 7.4.1708 (Core)
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
nohup (GNU coreutils) 8.22
etcd Version: 3.1.0
Git SHA: 8ba2897
Go Version: go1.7.4
Go OS/Arch: linux/amd64

Seán C. McCord

unread,
Dec 6, 2017, 12:35:35 PM12/6/17
to Francisco Andrade, etcd-dev
You're using CentOS 7, which comes with systemd.   Is there some reason you are not using it and journald?  I know you assert that you want a file in particular, but you can always export one from systemd-journald.


--
You received this message because you are subscribed to the Google Groups "etcd-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to etcd-dev+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Seán C McCord
CyCore Systems, Inc

Francisco Andrade

unread,
Dec 6, 2017, 1:32:46 PM12/6/17
to etcd-dev
I'll take a look at this option, maybe it'll be easier to use systemd than solving my current issue.

Thank you, Seán.
Reply all
Reply to author
Forward
0 new messages