Logstash runs from command line but not as a service

I have logstash and elastic search installed.

I'm trying to get logstash to read a csv file and populate ES

everything works fine when I run logstash from the command line using:

sudo /opt/logstash/bin/logstash -f /etc/logstash/conf.d/products.conf

but when running the logstash service the csv file isn't read and no index is created.

I've tried:

chmod 777 the csv file
moving the csv to /tmp/
editing the logstash config file (/etc/init.d/logstash) and changing LS_USER=root

i've checked my config file with --configtest and everything is ok

how do I get the logstash service to read the csv file?

i'm using CentOS 6.5

this is the output from the logstash.stdout log:

Writing garbage collection logs to ./logstash-gc.log
Sending logstash logs to /var/log/logstash/logstash.log.
Error: Expected one of #, input, filter, output at line 1, column 1 (byte 1) af$
You may be interested in the '--configtest' flag which you can
use to validate logstash's configuration before you choose
to restart a running system.

sudo /opt/logstash/bin/logstash -f /etc/logstash/conf.d/products.conf

You should never run Logstash as root, not even for testing.

this is the output from the logstash.stdout log:

Writing garbage collection logs to ./logstash-gc.log
Sending logstash logs to /var/log/logstash/logstash.log.
Error: Expected one of #, input, filter, output at line 1, column 1 (byte 1) af$
You may be interested in the '--configtest' flag which you can
use to validate logstash's configuration before you choose
to restart a running system.

You probably have another file in /etc/logstash/conf.d that Logstash has a problem with. Logstash will read all files from that directory.

yeah I did!! I had a random file in there, so I deleted it and it's all working now!! thanks for your help! :smile_cat:

ok noted! thanks!