Question
· Jul 28, 2021

How to schedule a Production to run only during office hours?

Hi

Is there any way to schedule a production to run only during office hours ?

Thanks
 

Discussion (4)1
Log in or sign up to continue

As I know, there is no way to have a schedule for the whole production. Just only services can have scheduled.

With working hours 8:00-18:00, will be something like this.

START:WEEK-*-01T08:00:00,STOP:WEEK-*-01T18:00:00,START:WEEK-*-02T08:00:00,STOP:WEEK-*-02T18:00:00,START:WEEK-*-03T08:00:00,STOP:WEEK-*-03T18:00:00,START:WEEK-*-04T08:00:00,STOP:WEEK-*-04T18:00:00,START:WEEK-*-05T08:00:00,STOP:WEEK-*-05T18:00:00

Hello,

It is possible, but not on the graphical level or management portal.
You would have to write ObjectScript routines and schedule them via task schedulers. 

The start task script should have something like:

Class YourAplication.ManualProductionStart Extends %SYS.Task.Definition
{

Parameter TaskName = "ManualProductionStart";

Method OnTask() As %Status
{
    Set tSC = Quit ##class(Ens.Director).StartProduction("InsertNameOfYouPrduction")
    If ( $System.Status.IsError( tSC ) ) {
    {
        Do ##class(%SYS.System).WriteToConsoleLog( "Error in ManualProductionStart: " _ ##class(%SYSTEM.Status).GetErrorText( tSC ) )
    }
    Quit ##class(%SYSTEM.Status).OK()
}

}

In [System > Task Manager > New Task] create a scheduled task named, for example, ManualProductionStart.
It should be daily, for example: 08:00

The stop script file should have something like:

Class YourAplication.ManualProductionStop Extends %SYS.Task.Definition
{

Parameter TaskName = "ManualProductionStop";

Method OnTask() As %Status
{
    Set pTimeout = 60 /// means 60 seconds to stop all transacitons
    Set pForce = 0 /// If you set to 1 it will performance a force stop, not ideal, could brak integraty.
    Set tSC = Quit ##class(Ens.Director).StopProduction(.pTimeout,.pForce)
    If ( $System.Status.IsError( tSC ) ) {
    {
        Do ##class(%SYS.System).WriteToConsoleLog( "Error in ManualProductionStop: " _ ##class(%SYSTEM.Status).GetErrorText( tSC ) )
    }
    Quit ##class(%SYSTEM.Status).OK()
}

}

In [System > Task Manager > New Task] create a scheduled task named, for example, ManualProductionStop.
It should be daily, for example: 18:00

But.

A major question. Why the need to start/stop production? 
Fail me to see a plausible reason to do so. Integration plataform should be a 24/7 application.
It more common some business services / operations had a delimited scheduled hour, not all the production.

And if you will use CronMaker you can go with two following commands.

First to start Production every working morning:

USER>zw ##class(dc.cron.task).Start("Start Production","0 0 8 ? * MON-FRI *","##class(Ens.Director).StartProduction(""InsertNameOfYouPrduction"")",1,.taskId)

And to stop Production every working evening:

USER>zw ##class(dc.cron.task).Start("Start Production","0 0 8 ? * MON-FRI *
","##class(Ens.Director).StopProduction(60,0)",1,.taskId)