Reputation: 877
currently I need to start a java application from upstart file and monitor it with monit, but needs a pid file.
I set the application user to be wwww-data:adm using
setuid www-data
setgid adm
and then
script
echo $$ > /var/run/logstash.pid
exec java -jar logstash.jar agent -f logstash.conf --log logstash.stdout
end script
error log shows that
/proc/self/fd/9: 2: /proc/self/fd/9: cannot create /var/run/logstash.pid: Permission denied
How can I write the pid file?
ps. I used start-stop-daemon and it tells "can not create Java Virtual Machine"
Upvotes: 1
Views: 775
Reputation: 13
Files and directories in /run and /var/run are not persistent across reboot.
Workaround - We can solve this by making a sub-directory every time a system comes up, via init scripts.
I guess monit does not have an inbuilt solution to solve this. I would like to know the ideal solution for this, if someone comes up.
Upvotes: 0
Reputation: 877
I finally solved it by adding a folder owned by www-data:adm in /var/run and put pid file there.
Upvotes: 1