[systemd-devel] Logroate + Pass signal to executable in container (nspawn)

Peter Paule systemd-devel at fedux.org
Mon Feb 23 06:12:13 PST 2015


Hi,

I run "nginx" in a container which itself is under systemd-control. All
error messages are put to stderr and the incomming requests are logged in
access.log. To reduce the filesize I want to rotate the access.log.

I see two possibilities to make nginx release the file handle:
   * Restart service
   * Send signal USR1 or whatever it needs to the service

Does it make sense to send SIGUSR1 (or whatever signal it needs) to
nginx to rotate the logs afterwards or is it ok to restart the whole
service because systemd will buffer all incoming request - though socket
activation is not in use? I'm not sure, what's best for this use case.

Any ideas? Thanks a lot.

/pp

This is the service.unit

   [Unit]
   Description=Webservice for %I

   [Service]
   EnvironmentFile=/etc/default/machines/%I.conf
   Environment="WWW_DIR=/srv/machines/%I"
   Environment="LOG_DIR=/var/log/machines/%I"
   Environment="SITES_DIR=/etc/machines/%I/sites-enabled"
   Environment="CONFIG_DIR=/etc/machines/%I/other-config"
   Environment="SSL_DIR=/etc/ssl/machines/%I"
   ExecStart=/usr/bin/systemd-nspawn --register=no --ephemeral  
--bind-ro ${SSL_DIR}:/etc/ssl/nginx --bind-ro ${WWW_DIR}:/srv/www  
--bind ${LOG_DIR}:/var/log/nginx/ --bind-ro  
${SITES_DIR}:/etc/nginx/sites-enabled/ --bind-ro  
${CONFIG_DIR}:/etc/nginx/other-config/ -M docker-centos-nginx  
/usr/sbin/nginx
   KillMode=process

   [Install]
   WantedBy=network.target

And to make things easier for you to read, here's the expanded exec  
start commandline

   /usr/bin/systemd-nspawn \
     --register=no \
     --ephemeral \
     --bind-ro /etc/ssl/machines/www_example_org:/etc/ssl/nginx \
     --bind-ro /srv/machines/www_example_org:/srv/www \
     --bind /var/log/machines/www_example_org:/var/log/nginx/ \
     --bind-ro  
/etc/machines/www_example_org/sites-enabled:/etc/nginx/sites-enabled/ \
     --bind-ro  
/etc/machines/www_example_org/other-config:/etc/nginx/other-config/ \
     -M docker-centos-nginx \
     /usr/sbin/nginx




More information about the systemd-devel mailing list