Executing Ruby script from PHP

Status
You're currently viewing only ShuggyCoUk's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
this is an astonishing bad idea (doubly so since you're trying to use a really bad 'glue' layer that you *don't understand*)

I know you're likely not listening but it bears saying in case some other poor sap comes along and reads this thinking it's a good idea.

If you want to trigger something from php then start using some tool that decouples the 'trigger' from the event.

There are many solutions, including trivially a shared database that your rub script polls to look for new work and puts the results (if any) into. Better is to use a proper message queue of some form (since that's what you're basically re-implementing if you use the database).
 

ShuggyCoUk

Ars Legatus Legionis
10,387
Subscriptor++
What's wrong with that?

Do you not even see that clear evidence that *a* problem exists with doing it because *you don't know how to do it or to debug it when it goes wrong*

Regardless of the specifics of why such things happen, why they are in general a bad idea (which topham's mentioned) you have clear, incontrovertible information that you do not understand the glue you have chosen.

The bad thing is not that you have two separate tools, one of which wants to consume the output of the other (nor that the two tools are in different languages). That bad thing is that you are using *exec* to communicate between them.

For starters doing it this way means there is no way you can ever move it off the box[1], it is incredibly fragile, and it's non obvious that such coupling exists. debugging is heinous, it's opening all sorts of security risks (that you appear to not have considered since you haven't mentioned what mitigating factors exist), it's going to scale horribly (if at all), there's no easy way to version your dependency on the relevant ruby runtimes, it's not easy to monitor/timeout the child task, the list goes on but hopefully this is a flavour...

1. I note, with some sense of depression, that I heard of someone achieving this in a similar situation by calling ssh, then the relevant script <shudder>
 
Status
You're currently viewing only ShuggyCoUk's posts. Click here to go back to viewing the entire thread.
Not open for further replies.