-
Notifications
You must be signed in to change notification settings - Fork 3
Cron
The cron launcher (Launcher.php) parses the arguments and instances the Cron Manager. The Launcher.php is located under src/main/php/Tools/Cron/.
- "Free argument"/"Final argument": The class that will be croned.
- config(c): Optional. The process file configuration (this will load the process config so make sure it's correctly configured, and other settings).
In the configuration process file you can customize the cron's settings like manager and process logger, the config folder, the data folder, the process pid, the bootstrap class and bootstrap's resources.
Let's assume we have the cron TestProject_Cron_Everyday:
We need to do:
php Launcher.php TestProject_Cron_Everyday
This will use the default manager.xml and process.xml located on src/main/resources/config
If we want use a costumized process.xml we simply do:
php Launcher.php -c ~/testproject/src/main/php/resources/config/manager.xml TestProject_Cron_Everyday
If we need to pass some arguments to the cron we only have to add to the command something like "key=value", for example:
php Launcher.php -c ~/testproject/src/main/php/resources/config/process.xml TestProject_Cron_Everyday mail="[email protected]"
Global:
- zend-config.manager.processNamespace: the process namespace.
- zend-config.manager.logPath: the path where the logs will be saved.
For loggin: the logger configuration accept the arguments for any Zend_Log_Writer. The arguments need to be on zend-config.manager.log in manager.xml. You have to pass writer's name (zend-config.manager.log.writerName) and his namespace (zend-config.manager.log.writerNamespace).
For process:
- zend-config.process.data.dir: the data's folder.
- zend-config.process.configDir: the process config folder.
- zend-config.process.logPath: the process log folder.
- zend-config.process.pid.path: the pid folder.
- zend-config.process.pid.file: the pid filename.
- zend-config.process.outputFile: the output file.
- zend-config.process.app.bootstrap.class: the bootstrap's class name,
- zend-config.process.app.bootstrap.path: the bootstrap's filename.
- zend-config.process.app.bootstrap.resources: the bootstrap resources that the process will need. If a process need some service/module which require to be properly initialized, we put the function located in bootstrap for that purpose.
Examples of logger configuration:
For file logger:
- zend-config.manager.log.fileLogger.writerParams.stream: the stream's name.
- zend-config.manager.log.fileLogger.writerName: the writer's name.
- zend-config.manager.log.fileLogger.writerNamespace: the writer's.
For mail logger:
- zend-config.manager.log.mailLogger.writerName: the writer's name.
- zend-config.manager.log.mailLogger.writerNamespace: the writers
- zend-config.manager.log.mailLogger.writerParams.to: the receiver's mail.
- zend-config.manager.log.mailLogger.writerParams.from: the sender's mail.
- zend-config.manager.log.mailLogger.writerParams.subject: the mail's subject.
- zend-config.manager.log.mailLogger.writerParams.transport: the mail's transport.
- zend-config.manager.log.mailLogger.writerParams.host: the host.
- zend-config.manager.log.mailLogger.writerParams.config: all the configuration data necessary.
For SMTP mail logger:
- zend-config.manager.log.mailLogger.writerParams.config.name: the name.
- zend-config.manager.log.mailLogger.writerParams.config.port: the port.
- zend-config.manager.log.mailLogger.writerParams.config.ssl: only if is required.
- zend-config.manager.log.mailLogger.writerParams.config.auth: ony if is required.
- zend-config.manager.log.mailLogger.writerParams.config.username: the username.
- zend-config.manager.log.mailLogger.writerParams.config.password: the password.
For example:
<zend-config>
<manager>
<fileLogger>
<writerParams>
<stream>manager.log</stream>
</writerParams>
<writerName>LazyStream</writerName>
<writerNamespace>ZendExt_Log_Writer</writerNamespace>
</fileLogger>
<mailLogger>
<writerName>Mail</writerName>
<writerNamespace>ZendExt_Log_Writer</writerNamespace>
<filterName>Priority</filterName>
<filterParams>
<operator><![CDATA[<=]]></operator>
<priority>2</priority>
</filterParams>
<writerParams>
<to>[email protected]</to>
<from>[email protected]</from>
<subject>Subject!</subject>
<transport>smtp</transport>
<host>smtp.example.com</host>
<config>
<name>example.com</name>
<port>587</port>
<ssl>tls</ssl>
<auth>login</auth>
<username>[email protected]</username>
<password>password</password>
</config>
</writerParams>
</mailLogger>
</manager>
<process>
<data>
<dir>data/</dir>
</data>
<configDir>resources/config/processes</configDir>
<logPath>log/</logPath>
<log>
<fileLogger>
<writerParams>
<stream>process.log</stream>
</writerParams>
<writerName>LazyStream</writerName>
<writerNamespace>ZendExt_Log_Writer</writerNamespace>
</fileLogger>
</log>
<pid>
<path>pid/</path>
<file>process.pid</file>
</pid>
<outputFile>php://stdout</outputFile>
<app>
<bootstrap>
<class>TestProject_Bootstrap</class>
<path>TestProject/Bootstrap.php</path>
</bootstrap>
<resources>
<Config />
<DbInit/>
</resources>
</app>
</process>
</zend-config>