Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

CLI issues (a very long story)


Go to End


4 Posts   1946 Views

Avatar
ElvinasL

Community Member, 2 Posts

14 November 2015 at 12:16am

Hi,

Lately i've spent a lot of time trying to solve some problems that I had (and still have) on one of my projects. I've found out that I've ran into two separate issues that were already known and have a github ticket. I've made some workarounds and it works now. But I've got a feeling that maybe my implementation is wrong and I need a advice how to do things correctly. Also I have some suggestions too.

The main reason why I've ran into these issues is that my project uses cronjobs. One of them must be run every 15 mins. Cronjobs are cofigured on DirectAdmin Web Control Panel.

So the first thing is that documentation doesn't mention (at least I didn't found where) that I need to do a flush before running my task (at least it is preferable). That's because SS creates separate manifest for every user. Flushing with HTTP request rebuilds manifest only for HTTP server user but not for cron user (#3092). I understand the reason why it is implemented in this way, but would useful to use other user's manifest if needed (passing username via CLI parameter or etc.). Of course it is possible to run conjob on the same user as HTTP server runs, but it is not always possible (at least DirectAdmin doesn't let me change it).

My cronjob command looked like this then:
php framework/cli-script.php / "flush=all" > /dev/null && php framework/cli-script.php /MyJob

But then my error log started to fill up with the messages about permission denied in /assests/_combinedfiles/. It was because the flush command was made on my index page and combined files were created by the cron user. So i tried to set Filesystem::file_create_mask to 02777 but then I realized that this property is not used at all anywhere in code... :) Also I checked Requiremets class and found that it does not use Filesystem or File to create combined file at all.

So I modified my command and everything looked OK then:
php framework/cli-script.php /dev/ "flush=all" > /dev/null && php framework/cli-script.php /MyJob

It still cleared /assests/_combinedfiles/ but it didn't create new ones, so apache user could recreate them.
But does it really necessary to clear this folder when I only need to rebuild the manifest? SS creates different manifest cache for every user to avoid user permission errors but it does writing/deleting in "shared" /assests/_combinedfiles/ folder. CLI does not use combined files so why to mess with it anyway?

After some time my client started to complain that he cannot work on admin. From time to time he has to reload the page because admin becomes irresponsible. After some digging I realized that I ran into #4553. Every 15mins cronjob clears /assests/_combinedfiles/ and lib.js has to be recreated. This is a very good example that ]hafriedlander's suggestion how to fix this issue is correct. Currently I use tractorcow's PR as a quickfix. At least my client can work with admin again.

So that's my story :) Sorry for the looog post.

P.S. It would be very useful to have a list of "know issues" (with the links to github) that are too difficult to fix or currently impossible to fix at all. Let's say Developer guides / Cli page could have a "known issues" list with #3092 and e.t.

Avatar
Sh33pDawg

Community Member, 2 Posts

18 April 2016 at 8:15pm

Hi ElvinasL

Thank you for taking the time to post. FWIW; you pointed me in the right direction to solve an issue.

i.e. my command line would not work and gave me the default page text back, despite working in the browser. So I flushed and built via the CLI and now it works.

It might be worth noting that my command line was as follows:

sake dev/build "flush=all"

Thanks again.

Avatar
mi32dogs

Community Member, 75 Posts

22 April 2016 at 5:37pm

Hi,
could you explain how you have setup your cron jobs? I have been trying to setup some cron jobs without success.
I first tried it as a BuildTask but when I setup the cron job via . /framework/cli-script.php it redirects to the login page.
Then I tried it as a controller, setup a path and from the browser it works fine without login in, but again if I run it from the command line via . /framework/cli-script.php it redirects to the login page.

How have you set it up?

Thanks

Avatar
mi32dogs

Community Member, 75 Posts

23 April 2016 at 7:08am

Ok I found a way to get the controller version to work. Still some problems but it is running.

Instead of:
php framework/cli-script.php / "flush=all" > /dev/null
what does not work on my server I do

php framework/cli-script.php dev/null/ flush=all
that works for me