Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#813262
Hello,

I have the following problem. I use a intermediate timer event and a scripttask in combination.
See the picture
process.PNG
process.PNG (28.69 KiB) Viewed 4908 times
It is a ordering and deploy process for virtual machines. In the scripttaks I proceed steps to search for an IP-address and servername in our central system QIP second step is automatical documentation and third step is a scripttask to document the work in a ticketsystem.
All these scripttasks use php code with curl to do REST api calls. Some of them espacially the first scripttask need 14 seconds to execute.
The cron for intermediate timers is set to every 5 minutes.
The intermediate timer events are all set to 1 minute.

When we proceed one instance of the process everything works fine. If there are three or four instances of the process and all of them go together in the que for the first intermediate timer event the first instance works fine, but the second breaks in an interrupt state. When we reassign the case to a person the task isn't finished and the workload has never been done.
So my first speculation was that the execution time of PHP isn't long enough. So I increase the value to 5 minutes. --> Doesn't helped.
At second I piped the output from the timereventcron.php to a LOG-file. I also added an output to my scripttask with time Stamp and kind of Script.
That have been intresting:
Code: Select all
^[[0;35;32mProcessing workspace: workflow^[[0m
^M+------------------------------------------------+
^M| Not exists any record to start a new case, on date "2018-02-19 09:00:03 (UTC +00:00)"
^M+------------------------------------------------+
^M| > Continue the case #98
^M| > Routing the case #98...
^M|     - OK
^M|
^M| > Continue the case #100
^M| > Routing the case #100...
QIP Task 09:00:04QIP Task 09:00:18^M|     - OK
^M|
^M| > Continue the case #101
^M| > Routing the case #101...
QIP Task 09:00:19Finished 1 workspaces processed
Done!
Normaly when just one or no case in the que of intermediate timer events it looks like that:
Code: Select all
^[[0;35;32mProcessing workspace: workflow^[[0m
^M+------------------------------------------------+
^M| Not exists any record to start a new case, on date "2018-02-19 09:05:03 (UTC +00:00)"
^M+------------------------------------------------+
^M| > Continue the case #98
^M| > Routing the case #98...
Ticket Task 09:05:02Ticket Task 09:05:04^M|     - OK
^M|
^M| > Continue the case #100
^M| > Routing the case #100...
^M|     - OK
^M+------------------------------------------------+

Finished 1 workspaces processed
Done!
So I thought that the scripttask was interrupted by something of processmaker but I don't know why.

I also tried to increase the PHP execution time by adding this line to my script tasks:
Code: Select all
set_time_limit(60);
I added that because I speculated that the processmaker add alle the scripttasks to one big task together and that takes to much time to execute. This line should reset the timer for the execution.
But I'm now at a point where I don't belive that the time is the problem.

But what can be the problem or how can I find it?
Can someone help me?
Kind regards
Timo
#813281
Here it is.
Is it what you mean? It's our /etc/cron.d/processmaker
Code: Select all
# ProcessMaker-Cron-Scripts, every 5 minutes from 6:00h to 18:55h, Monday to Friday
*/5  6-18 * * 1-5 apache /opt/processmaker/pm-allcronjobs.sh > /dev/null 2>&1
# Update rights to files, Monday to Friday at 21:15
15 21 * * 1-5 root /opt/processmaker/pm-update-rights.sh > /dev/null 2>&1
# Logrotate for ProcessMaker, Monday to Friday at 21:30
30 21 * * 1-5 root /usr/sbin/logrotate -s /opt/processmaker/pm-logrotate.status /opt/processmaker/pm-logrotate.conf
# Delete old logfiles every Saturday at 21:30
30 21 * * 6 root /opt/processmaker/pm-deleteoldlogs.sh > /dev/null 2>&1
#813285
Ok I found out that it doesn't have to do with the Time how long a Cron job runs.
I build a process which has just two tasks and a intermediate timer event. The Script task runs a code to calculate prime integers which runs 27 seconds. After that I fired 4 cases and all of them ended correct.
I try more things
#813290
Hello,

my problem has nothing to do with time or something like that. It is quite easy.
I rduced all the komplexity of my process to just two tasks one script and one manual task. Then I found out that the function in my scipt task was the problem because it have been redefined more than once when I fired the process to multiple cases and they all gone in the que of the intermediate timer event at the same time.
Till now I thought processmaker would do every scripttask as a single instance and don't match each scripttask to a big scripttask just with different application variables. I don't know the reason for what this is designed for.
Maybe this could be a security issue if it can be possible to get the data of an other case.

Greetz
Timo
#813308
Sure I can:
Here is my Scripttask
Code: Select all
echo "Start TEST Task " . date('h:i:s',time()) . "\n";
$zeit=time();


	function pizahlen() {
		//No reason for this function just calculate approx 30 seconds
		echo "beginn Function\n";
		for ($j=2; $j <= 600000; $j++){
		$maxtest = sqrt($j);
				for ($i = 2; $i <= $maxtest; ++$i) {
						if ($j % $i == 0) {
							   // echo "false";
						}
				}
		}
		echo "end Function\n";
	}

pizahlen();
$zeit=time()-$zeit;
@%durchlaufzeit=$zeit;
echo "Durchlaufzeit: " . $zeit ."\n";
echo "Ende TEST Task " . date('h:i:s',time()) ."\n";
This would fail if the process is more than once fired.
This is my work arround for that problem:
Code: Select all
echo "Start TEST Task " . date('h:i:s',time()) . "\n";
$zeit=time();

if (!function_exists ('pizahlen')){
	function pizahlen() {
		//No reason for this function just calculate approx 30 seconds
		echo "beginn Function\n";
		for ($j=2; $j <= 600000; $j++){
		$maxtest = sqrt($j);
				for ($i = 2; $i <= $maxtest; ++$i) {
						if ($j % $i == 0) {
							   // echo "false";
						}
				}
		}
		echo "end Function\n";
	}
}
pizahlen();
$zeit=time()-$zeit;
@%durchlaufzeit=$zeit;
echo "Durchlaufzeit: " . $zeit ."\n";
echo "Ende TEST Task " . date('h:i:s',time()) ."\n";
I also attached the whole process (the simplified one to just focus on the problem).
So trigger the process 2 or more times and wait until the timereventcron would be executed or execute it after one minute of the last triggered case and you can see the issue. I also added in the process 3 triggers. One with just the code to calculate the prime integers, one with code in a function and one with code in a function with the work around. Let me know if this is a bug.
Attachments
Process with 3 triggers
(48.46 KiB) Downloaded 252 times
Want to create your own meme coin?

In the world of cryptocurrencies, a unique and exc[…]

The market for cryptocurrencies is demonstrating a[…]

What's SAP FICO?

Embarking on a dissertation can be one of the most[…]

Hello. For rental housing, there are software solu[…]