Separating java stdout and stderr with systemd and without filling journal
I'm trying the following for Logstash to replace its init.d script. Basically, wrapping it with bash to provide stdout and stderr redirection. Not sure if this is quite what you want, or would want to use (it's not too hideous, but clearly not how systemd wants you to do it), but I needed something to make it start after Elasticsearch, and I didn't want my team to notice anything different about where the log files ended up, so hopefully this will tide me over until they provide one of their own:
[Unit]
Description=Logstash
After=elasticsearch.service
Requires=elasticsearch.service
[Service]
Type=simple
User=logstash
Group=logstash
ExecStart=/bin/bash -c 'exec /opt/logstash/bin/logstash agent \
-f /etc/logstash/conf.d \
-l /var/log/logstash/logstash.log \
>/var/log/logstash/logstash.stdout \
2>/var/log/logstash/logstash.err'
WorkingDirectory=/var/lib/logstash
LimitNICE=19
LimitNOFILE=16384
Restart=always
[Install]
WantedBy=multi-user.target
Edit: I just realized I could create /etc/systemd/system/logstash.service.d/after-es.conf
as follows and not have to rewrite their init.d script:
[Unit]
After=elasticsearch.service
Requires=elasticsearch.service
Oh well, leaving the above in case it's useful.