Jump to content

async script on trigger


hampsterx

Recommended Posts

Hi All,

Might be more of a linux question than plastic but here goes.

I have a bash script that is being run on a plastic trigger (after-checkin). Basically it has some curl commands in there. I have set the flags on curl to limit connection time to 1 second and request time to 1 second. However, within plastic you can notice there is a delay when you checkin. It's not a big problem but it would be better if the script (or the curl commands) were run async so it didn't hold up the plastic client.

I can understand *before* triggers needing to wait for the script finishes for a result to determine whether to cancel the operation but *after* doesn't make much sense to me.

Anyhoo, someone got a quick fix?

PS Very shortly I want to write up our plastic workflow/setup for the benefit of other web development teams, very satisfied with plastic :)

TiM

Link to comment
Share on other sites

Mmmmmmm if you run from your trigger program a command with "nohup" first like this "nohup myAsycnProgram.sh &" I think your main trigger program can end and your Async program can continue.... Does it makes sense?

PS Very shortly I want to write up our plastic workflow/setup for the benefit of other web development teams, very satisfied with plastic :)

Cool!!! :) Thanks!!!! :)

Link to comment
Share on other sites

  • 1 year later...

oops, seems I never got this thing working correctly and it was/is always waiting on script to finish.

 

Can you confirm plastic is not waiting for process to finish. 

 

If I try

 

 

"nohup myAsycnProgram.sh &"
 

It still waits for it to finish.

 

Even if you try one script triggering another. it doesnt work either..

 

 

root@plastic:/opt# cm listtriggers
     1 update subs     /opt/pl.sh      beta       after-checkin
 
/opt/pl.sh
 
#!/bin/sh
nohup /opt/plastic.sh &
exit 0
 
 
If I run this from command line it always finishes right away, but from trigger it does not !
 
Thnx, TiM
 
Link to comment
Share on other sites

I also want to run a Python script after checkin. Really after because I want to retrieve to file changes of the checkin. Therefore I run the cm log command within the script. But at that time when the script runs the cm command the changeset doesn't exist yet. 

So, i tried to do this on Windows using start (asynchronous start of a process) but the plastic client still wait's until the script is finished.

 

In the trigger i start a bat file that contains "start C:\python27\python.exe E:\aftercheckin.py"

 

Why does the after-checkin trigger wait until all triggered programs are completed before commiting the changeset?

Link to comment
Share on other sites

Hello,

 

I´ve tested some possibilities to run async after-checkin triggers:

- In C# you can use the Process class. I´ve made some examples and the trigger works asynchronous from the checkin ( http://www.dotnetperls.com/process-start )

- In Python exists a Process class, but it seems that the trigger doesn't work asynchronous (http://docs.python.org/dev/library/multiprocessing.html)

- If you are running python scripts, you may find this post interesting. It explains how to run a phyton script from a C# Process class (http://stackoverflow.com/questions/3823880/python-c-is-ironpython-absolutely-necessary).

 

Best regards,

carlos

Link to comment
Share on other sites

  • 5 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...