Logrotation on Centos7

With new version installed on CentOS 7 aerospike stops write the pid file:

WARNING (as): (as.c:430) will not write PID file in new-style daemon mode

As a result logrotatoin doesn’t work anymore:

/bin/kill -HUP `cat /var/run/aerospike/asd.pid`

How to fix this?

1 Like

For CentOS7 you should be able to use journalctl. The configuration’s logging context should be setup to use console. The default configuration for the CentOS7 package comes setup this way for systemd. (There may have been other changes to config in the service context to support systemd.)

I’m using journalctl, I don’t have problems with systemd too.

logging {
  file /var/log/aerospike/aerospike.log {
    context any info
  console {
    context any warning

I just need working logrotation for logs beside journalct

Alright well,

You could change

cat /var/run/aerospike/asd.pid


systemctl show aerospike | egrep "^MainPID" | cut -d= -f2

or this would likely be fine:

pgrep 'asd'
1 Like

@kporter, of course, I can write any scripts around it to do it, but I didn’t expect that aerospike will disable pidfile option in aerospike.conf without normal support systemd: I’m talking about PIDFile - systemd - ArchWiki

You should specify PIDFile= as well so systemd can keep track of the main process.

Original service file comes with the latest Enterprise Edition:

Description=Aerospike Server

ExecStart=/usr/bin/asd $ASD_OPTIONS --config-file $ASD_CONFIG_FILE --fgdaemon


Adding PIDFile doesn’t help:

# systemctl show aerospike | grep PIDFile
# cat /var/run/aerospike.pid
cat: /var/run/aerospike.pid: No such file or directory

Maybe only I can’t see any logic here.

Read paragraph before your excerpt:

Type=simple (default): systemd considers the service to be started up immediately. The process must not fork. Do not use this type if other services need to be ordered on this service, unless it is socket activated.

Type=forking: systemd considers the service started up once the process forks and the parent has exited. For classic daemons use this type unless you know that it is not necessary. You should specify PIDFile= as well so systemd can keep track of the main process.

PIDFile is suggested for Type=forking; Aerospike is using Type=simple (default).

Yeap, originally I was reading another page. @kporter, do you think is it a good idea to update default systemd sevice file with reload command?

ExecReload=/bin/kill -s HUP $MAINPID

It works for me.

Looks reasonable to me, will suggest such a change to the packaged file as well.