[Catalyst] From Development to Production.

Andrew catalystgroup at unitedgames.co.uk
Tue Mar 8 14:53:49 GMT 2016


Does anyone have any advice?
Looking for the best way to handle permissions.

My web app stores data to text files, in a directory.

While it makes sense to have a development server, and a production  
server, when it comes to updating the scripts in the lib folder.... it  
doesn't make much sense to duplicate the data folder with all the text  
files between development and production servers.
Mainly because users using the web app will be generating data that is  
saved there, so the production server's data folder will always be  
more relevant/populated - we don't want to overwrite user data all the  
time.

So, if data is stored in a data folder on the production server,
I need a system whereby....

The Production Server can:
Read and write to a file it creates.
Read a file the Dev Server created.
Write to a file the Dev Server created.

and where...

The Development Server can:
Read and write to a file it creates.
Read a file the Production Server created.
Write to a file the Production Server created.

I was taught Path::Tiny is the best plugin to use in Catalyst for  
reading and writing to files (let me know if you recommend any others).

With that, I found:

path($datapath."test.txt")->spew_utf8($bitofdata);
....worked, because spew creates a temporary file and then overwrites  
the old one. This means, after the Dev server writes to the file, it  
has ownership and group permissions of the Dev server, and after the  
Production server writes to the file, it has ownership and group  
permissions of the Production server.

path($datapath."test.txt")->append_utf8($newbitofdata);
...however, which attempts to open an existing file and add an extra  
line, results in an error - permission is denied.
I assume that's because the Prod user can't access files owned by the  
Dev user, and vice versa.

So should I use spew always, or is there a way to sort out the permissions?
So that both users on the server can read and write to files in the  
data directory?

Or is there a way for the Dev Server to interact with files using the  
Prod server's userid instead of the dev server userid?

I managed to find some lines on the internet saying how to create a  
group, add users to the group, and then set ownership and group of  
files and folders. Trouble is, any new files or folders I then create  
in my Perl script, are owned by the userid associated with the server  
that created them.

What's the best practice?
To give a prod and dev server, equal access to a directory on the  
production server?

Server is a shared hosting VPS, with multiple user directories. One of  
these user directories is the development server, the other is the  
live website. Server is Apache / CentOS.

Many thanks in advance,

Yours,
Andrew




More information about the Catalyst mailing list