I'm using Laravel 5.1, with Log set to be generated daily.
I'm heavily using Jobs. Web server is Apache, so therefore PHP is executed as
apache user, so at the end of the day, a new log file is generated by apache user and file permission is
0644. I've workers configured via Supervisor, which is being run by apache user. (So far so good)
Now for a random spike in Queue, I've a script setup to run more worker (Consumers of Queue). Problem I'm facing is since Log file is generated with 0644 permission, other users doesn't have write permission to file.
Few solutions I can think of is -
rootuser (can't do, as I don't have permissions)
0646at 00:00:00 each day (also requires root)
0646(Can't be reliable, what if
apachecreates it first)
apacheuser (Since no root, so this is not possible)
So my question is what is the best way to do it, it looks like a general problem to me, which any developer could face. Or is there any better way to do this apart from above mentioned methods.
[..] other users doesn't have write permission to file.
Are you sure you want those users to access the file directly? You could just add an API to your laravel app to serve this file (or even only some filtered data from it). This also allows you too have more fine grained access control within your app etc.