DA Custom Scripts

sysdev

Verified User
Joined
Jul 16, 2007
Messages
378
Anybody know if there's a custom script that get's triggered when a user changes the php version for a domain?
 
Hmm, too bad. I 'need' it because I decided to give every user his own php-fpm master process. I 'could' give every user an own process for every php version, but I'd rather not because most users won't be using all php versions.

And because you're gonna ask 'why do that, we already have a shared php-fpm process for every php version...?'

It's because I want cgroups to work with the php-fpm processes. When a php fpm serive for a user is (re)started, it's PID is added to the cgroup2 filesystem and (for now) it's cpu resources are limited to whatever is specified in the reseller package.

But it's a project in development, to maybe there's a better way to do it. Time will tell :)
 
Maybe try the all_pre/post.sh hooks ?

The domain modification hook didn't seem to get triggered for me when changing the php version for the domain (I guess the PHP Selector isn't technically under domain modification but rather a separate option on the same page), but you could do this instead:

Use the all_pre/post.sh hooks with content like this:

Bash:
#!/bin/sh

# is php version being changed for a domain via the php selector
if  ["$command" = "/CMD_DOMAIN" ] && [ "$action" = "php_selector" ]; then
  #my code
fi
exit 0;

If you need to see what variables are available to you, do this and then trigger the script by temporarily changing a domain's PHP version via the domain's PHP version selector:

Bash:
#!/bin/sh
if  ["$command" = "/CMD_DOMAIN" ] && [ "$action" = "php_selector" ]; then
  echo ""  >> environment.txt
  echo "RUNNING $0 : " >> environment.txt
  echo `env` >> environment.txt
fi
exit 0;

That will print the environment variables and what they are set to for that instance to the file /usr/local/directadmin/environment.txt.

Hope this helps! :)
 
Yes, thanks! This helps a lot. I totally forgot about the all_p*.sh.

I owe you a coffee! :)

John
 
Back
Top