Closed esetnik closed 5 years ago
Actually your closure do not work at all - https://3v4l.org/bjv0n
Fatal error: Uncaught TypeError: Argument 1 passed to test() must be an instance of boolean, bool given
There is no problem with Crunz itself :)
The issue is not that the closure is incorrect (I purposely made it this way). The issue is that crunz does not report the error. Look at my output from crunz. It does not contain any information about the error.
You are right, output could be more "verbose". Would you like to provide a PR for this issue?
I did some debugging and I found that I actually get the correct output when I have:
// php.ini
log_errors = On
So it seems that crunz logs an empty error if there is a PHP Fatal Error
and log_errors = On
is not set. Maybe crunz can install a custom error handler and log to monolog regardless of the log_errors
setting. In my opinion, crunz should never log an empty error message.
Crunz actually do not omit errors, there is issue with writing error to stderr
instead of stdout
:
// \Crunz\EventRunner
protected function handleError(Event $event)
{
// ...
$this->display($event->getProcess()->getErrorOutput());
// ...
}
As you can see Crunz show error output (stderr
) $event->getProcess()->getErrorOutput()
, but error is in stdout
. Possible solution is, as you said, redirect errors to error output. Maybe a better idea is to log whole output to give some context to error?
@esetnik i improved error logging/displaying, could you test changes on https://github.com/PabloKowalczyk/crunz/tree/improve-error-logging ?
Hi @PabloKowalczyk thank you for your work. I have not had an opportunity to test the changes yet, but I reviewed the commit and it makes sense to me. The only thing that's questionable is the formatting of the error output with <error>
tags. I will leave it up to you how you want it to present, but in my opinion it's a bit strange to have tags in logs.
Mentioned <error>
is used only for display
and it is not a problem because Symfony's formatter will turn it into white text with red background, only on supported terminals.
Logs always have "raw" content, without any tags.
Merged and released in https://github.com/lavary/crunz/releases/tag/v1.10.0. Thanks @esetnik.
@PabloKowalczyk I actually found that after v1.10.0 with log_errors = On
there is an empty output on an exception thrown. I had to revert to v1.9.0
@esetnik did you mean log_errors = On
in php.ini
?
Yes that is correct
I have this option enabled and everything working as expected. In your previous post, "empty output" mean empty cli console or empty file where Crunz stores error logs?
@esetnik seems errors displaying depends on display_error
. i have created PR which enables displaying errors ,could you test that version https://github.com/PabloKowalczyk/crunz/tree/show-all-errors?
BTW could could you paste output of command php -i | grep error
?
@esetnik you should see https://github.com/lavary/crunz/issues/161, seems related. If you still have issues feel free to open new issue.
@PabloKowalczyk thanks for the update and continued hard work. When the update becomes stable I will test the changes and let you know if it resolves things.
@PabloKowalczyk just tested with 1.11 and it's still not working. It logs the crunz.INFO
but the task output is missing. Here's a sample to reproduce:
root@a636be9c78e8:/usr/src/app/src# vendor/bin/crunz -V
Crunz Command Line Interface v1.11.0
command i'm running inside the container
root@a57cf902413f:/usr/src/app/src# vendor/bin/crunz schedule:run -vvv
Using config file /usr/src/app/src/crunz.yml.
Task source path '/usr/src/app/src/jobs'
Realpath for '/usr/src/app/src/jobs' is '/usr/src/app/src/jobs'
Task finder pattern '/usr/src/app/src/jobs/*Tasks.php'
Found 1 task(s) at path '/usr/src/app/src/jobs'
Timezone from config: 'UTC'.
Timezone for comparisons: 'UTC'.
Invoke Schedule's ping before
There is no ping before url.
Invoke Event's ping before.
There is no ping before url.
Invoke Event's ping after.
There is no ping after url.
[2019-01-24 16:05:00] crunz.INFO: Copying the project directory(object(Closure))
[] []
Task Copying the project directory status: success.
Invoke Schedule's ping after.
There is no ping after url.
src/jobs/TestTasks.php
<?php
use Crunz\Schedule;
$schedule = new Schedule();
$x = 12;
$schedule->run(function () use ($x) {
echo "hi";
echo $x;
})
->everyMinute()
->description('Copying the project directory');
return $schedule;
src/jobs/set_env.sh
#!/bin/bash
set -e
export SQL_DATABASE=$SQL_DATABASE;
export SQL_HOST=$SQL_HOST;
export SQL_USER=$SQL_USER;
export SQL_PASSWORD=$SQL_PASSWORD;
export SQL_PORT=$SQL_PORT;
export ENV=$ENV;
export SENDGRID_API_KEY=$SENDGRID_API_KEY;
src/jobs/start.sh
#!/bin/bash
set -e
envsubst < src/jobs/set_env.sh > /set_env.sh
chmod +x /set_env.sh
echo 'starting cron job daemon...'
cron -f
src/jobs/crontab
* * * * * . /set_env.sh; cd /usr/src/app/src && vendor/bin/crunz schedule:run -vvv > /proc/1/fd/1 2>/proc/1/fd/2
Dockerfile
FROM php:7.3-stretch
# Set timezone to America/New_York
ENV TZ=America/New_York
ENV php_vars /usr/local/etc/php/conf.d/docker-vars.ini
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& echo $TZ > /etc/timezone \
&& echo "date.timezone=\"$TZ\"" >> /usr/local/etc/php/conf.d/docker-vars.ini
RUN apt-get update && \
apt-get install -y --no-install-recommends gnupg \
apt-transport-https \
cron \
gettext
RUN ln -s /usr/local/bin/php /usr/bin/php
RUN mv $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini && \
echo "log_errors = On" >> ${php_vars} && \
echo "display_errors = On" >> ${php_vars} && \
echo "error_log = /dev/stderr" >> ${php_vars} && \
echo "display_startup_errors = On" >> ${php_vars}
RUN mkdir /usr/src/app
WORKDIR /usr/src/app
COPY . .
COPY src/jobs/crontab /etc/cron.d/jobs-cron
# COPY src/jobs/php.ini /usr/local/etc/php
RUN chmod 755 /etc/cron.d/jobs-cron
RUN crontab /etc/cron.d/jobs-cron
RUN chmod +x src/jobs/start.sh
RUN touch /usr/src/app/src/crunz
CMD ["src/jobs/start.sh"]
php -i (from inside container)
root@6e347f9b3dfb:/usr/src/app/src# php -i
phpinfo()
PHP Version => 7.3.1
System => Linux 6e347f9b3dfb 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64
Build Date => Jan 22 2019 21:52:29
Configure Command => './configure' '--build=x86_64-linux-gnu' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--enable-option-checking=fatal' '--with-mhash' '--enable-ftp' '--enable-mbstring' '--enable-mysqlnd' '--with-password-argon2' '--with-sodium=shared' '--with-curl' '--with-libedit' '--with-openssl' '--with-zlib' '--with-libdir=lib/x86_64-linux-gnu' 'build_alias=x86_64-linux-gnu'
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/etc/php
Loaded Configuration File => /usr/local/etc/php/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/conf.d
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-pdo_sqlsrv.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sodium.ini,
/usr/local/etc/php/conf.d/docker-php-ext-sqlsrv.ini,
/usr/local/etc/php/conf.d/docker-vars.ini
PHP API => 20180731
PHP Extension => 20180731
Zend Extension => 320180731
Zend Extension Build => API320180731,NTS
PHP Extension Build => API20180731,NTS
Debug Build => no
Thread Safety => disabled
Zend Signal Handling => enabled
Zend Memory Manager => enabled
Zend Multibyte Support => provided by mbstring
IPv6 Support => enabled
DTrace Support => disabled
Registered PHP Streams => https, ftps, compress.zlib, php, file, glob, data, http, ftp, phar, sqlsrv
Registered Stream Socket Transports => tcp, udp, unix, udg, ssl, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filters => zlib.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk
This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.3.1, Copyright (c) 1998-2018 Zend Technologies
_______________________________________________________________________
Configuration
Core
PHP Version => 7.3.1
Directive => Local Value => Master Value
allow_url_fopen => On => On
allow_url_include => Off => Off
arg_separator.input => & => &
arg_separator.output => & => &
auto_append_file => no value => no value
auto_globals_jit => On => On
auto_prepend_file => no value => no value
browscap => no value => no value
default_charset => UTF-8 => UTF-8
default_mimetype => text/html => text/html
disable_classes => no value => no value
disable_functions => no value => no value
display_errors => STDOUT => STDOUT
display_startup_errors => On => On
doc_root => no value => no value
docref_ext => no value => no value
docref_root => no value => no value
enable_dl => Off => Off
enable_post_data_reading => On => On
error_append_string => no value => no value
error_log => /dev/stderr => /dev/stderr
error_prepend_string => no value => no value
error_reporting => 22527 => 22527
expose_php => On => On
extension_dir => /usr/local/lib/php/extensions/no-debug-non-zts-20180731 => /usr/local/lib/php/extensions/no-debug-non-zts-20180731
file_uploads => On => On
hard_timeout => 2 => 2
highlight.comment => <font style="color: #FF8000">#FF8000</font> => <font style="color: #FF8000">#FF8000</font>
highlight.default => <font style="color: #0000BB">#0000BB</font> => <font style="color: #0000BB">#0000BB</font>
highlight.html => <font style="color: #000000">#000000</font> => <font style="color: #000000">#000000</font>
highlight.keyword => <font style="color: #007700">#007700</font> => <font style="color: #007700">#007700</font>
highlight.string => <font style="color: #DD0000">#DD0000</font> => <font style="color: #DD0000">#DD0000</font>
html_errors => Off => Off
ignore_repeated_errors => Off => Off
ignore_repeated_source => Off => Off
ignore_user_abort => Off => Off
implicit_flush => On => On
include_path => .:/usr/local/lib/php => .:/usr/local/lib/php
input_encoding => no value => no value
internal_encoding => no value => no value
log_errors => On => On
log_errors_max_len => 1024 => 1024
mail.add_x_header => Off => Off
mail.force_extra_parameters => no value => no value
mail.log => no value => no value
max_execution_time => 0 => 0
max_file_uploads => 20 => 20
max_input_nesting_level => 64 => 64
max_input_time => -1 => -1
max_input_vars => 1000 => 1000
memory_limit => 128M => 128M
open_basedir => no value => no value
output_buffering => 0 => 0
output_encoding => no value => no value
output_handler => no value => no value
post_max_size => 8M => 8M
precision => 14 => 14
realpath_cache_size => 4096K => 4096K
realpath_cache_ttl => 120 => 120
register_argc_argv => On => On
report_memleaks => On => On
report_zend_debug => Off => Off
request_order => GP => GP
sendmail_from => no value => no value
sendmail_path => -t -i => -t -i
serialize_precision => -1 => -1
short_open_tag => Off => Off
SMTP => localhost => localhost
smtp_port => 25 => 25
sys_temp_dir => no value => no value
syslog.facility => LOG_USER => LOG_USER
syslog.filter => no-ctrl => no-ctrl
syslog.ident => php => php
track_errors => Off => Off
unserialize_callback_func => no value => no value
upload_max_filesize => 2M => 2M
upload_tmp_dir => no value => no value
user_dir => no value => no value
user_ini.cache_ttl => 300 => 300
user_ini.filename => .user.ini => .user.ini
variables_order => GPCS => GPCS
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
zend.assertions => -1 => -1
zend.detect_unicode => On => On
zend.enable_gc => On => On
zend.multibyte => Off => Off
zend.script_encoding => no value => no value
zend.signal_check => Off => Off
ctype
ctype functions => enabled
curl
cURL support => enabled
cURL Information => 7.52.1
Age => 3
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
HTTP2 => Yes
GSSAPI => Yes
KERBEROS5 => Yes
UNIX_SOCKETS => Yes
PSL => Yes
HTTPS_PROXY => Yes
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host => x86_64-pc-linux-gnu
SSL Version => OpenSSL/1.0.2q
ZLib Version => 1.2.8
libSSH Version => libssh2/1.7.0
Directive => Local Value => Master Value
curl.cainfo => no value => no value
date
date/time support => enabled
timelib version => 2018.01RC2
"Olson" Timezone Database Version => 2018.5
Timezone Database => internal
Default timezone => America/New_York
Directive => Local Value => Master Value
date.default_latitude => 31.7667 => 31.7667
date.default_longitude => 35.2333 => 35.2333
date.sunrise_zenith => 90.583333 => 90.583333
date.sunset_zenith => 90.583333 => 90.583333
date.timezone => America/New_York => America/New_York
dom
DOM/XML => enabled
DOM/XML API Version => 20031129
libxml Version => 2.9.4
HTML Support => enabled
XPath Support => enabled
XPointer Support => enabled
Schema Support => enabled
RelaxNG Support => enabled
fileinfo
fileinfo support => enabled
libmagic => 533
filter
Input Validation and Filtering => enabled
Directive => Local Value => Master Value
filter.default => unsafe_raw => unsafe_raw
filter.default_flags => no value => no value
ftp
FTP support => enabled
FTPS support => enabled
hash
hash support => enabled
Hashing Engines => md2 md4 md5 sha1 sha224 sha256 sha384 sha512/224 sha512/256 sha512 sha3-224 sha3-256 sha3-384 sha3-512 ripemd128 ripemd160 ripemd256 ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,4 tiger192,4 snefru snefru256 gost gost-crypto adler32 crc32 crc32b fnv132 fnv1a32 fnv164 fnv1a64 joaat haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,5 haval224,5 haval256,5
MHASH support => Enabled
MHASH API Version => Emulated Support
iconv
iconv support => enabled
iconv implementation => glibc
iconv library version => 2.24
Directive => Local Value => Master Value
iconv.input_encoding => no value => no value
iconv.internal_encoding => no value => no value
iconv.output_encoding => no value => no value
json
json support => enabled
json version => 1.7.0
libxml
libXML support => active
libXML Compiled Version => 2.9.4
libXML Loaded Version => 20904
libXML streams => enabled
mbstring
Multibyte Support => enabled
Multibyte string engine => libmbfl
HTTP input encoding translation => disabled
libmbfl version => 1.3.2
oniguruma version => 6.9.0
mbstring extension makes use of "streamable kanji code filter and converter", which is distributed under the GNU Lesser General Public License version 2.1.
Multibyte (japanese) regex support => enabled
Multibyte regex (oniguruma) backtrack check => On
Multibyte regex (oniguruma) version => 6.9.0
Directive => Local Value => Master Value
mbstring.detect_order => no value => no value
mbstring.encoding_translation => Off => Off
mbstring.func_overload => 0 => 0
mbstring.http_input => no value => no value
mbstring.http_output => no value => no value
mbstring.http_output_conv_mimetypes => ^(text/|application/xhtml\+xml) => ^(text/|application/xhtml\+xml)
mbstring.internal_encoding => no value => no value
mbstring.language => neutral => neutral
mbstring.strict_detection => Off => Off
mbstring.substitute_character => no value => no value
mysqlnd
mysqlnd => enabled
Version => mysqlnd 5.0.12-dev - 20150407 - $Id: 401a40ebd5e281cf22215acdc170723a1519aaa9 $
Compression => supported
core SSL => supported
extended SSL => supported
Command buffer size => 4096
Read buffer size => 32768
Read timeout => 86400
Collecting statistics => Yes
Collecting memory statistics => No
Tracing => n/a
Loaded plugins => mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password,auth_plugin_sha256_password
API Extensions =>
mysqlnd statistics =>
bytes_sent => 0
bytes_received => 0
packets_sent => 0
packets_received => 0
protocol_overhead_in => 0
protocol_overhead_out => 0
bytes_received_ok_packet => 0
bytes_received_eof_packet => 0
bytes_received_rset_header_packet => 0
bytes_received_rset_field_meta_packet => 0
bytes_received_rset_row_packet => 0
bytes_received_prepare_response_packet => 0
bytes_received_change_user_packet => 0
packets_sent_command => 0
packets_received_ok => 0
packets_received_eof => 0
packets_received_rset_header => 0
packets_received_rset_field_meta => 0
packets_received_rset_row => 0
packets_received_prepare_response => 0
packets_received_change_user => 0
result_set_queries => 0
non_result_set_queries => 0
no_index_used => 0
bad_index_used => 0
slow_queries => 0
buffered_sets => 0
unbuffered_sets => 0
ps_buffered_sets => 0
ps_unbuffered_sets => 0
flushed_normal_sets => 0
flushed_ps_sets => 0
ps_prepared_never_executed => 0
ps_prepared_once_executed => 0
rows_fetched_from_server_normal => 0
rows_fetched_from_server_ps => 0
rows_buffered_from_client_normal => 0
rows_buffered_from_client_ps => 0
rows_fetched_from_client_normal_buffered => 0
rows_fetched_from_client_normal_unbuffered => 0
rows_fetched_from_client_ps_buffered => 0
rows_fetched_from_client_ps_unbuffered => 0
rows_fetched_from_client_ps_cursor => 0
rows_affected_normal => 0
rows_affected_ps => 0
rows_skipped_normal => 0
rows_skipped_ps => 0
copy_on_write_saved => 0
copy_on_write_performed => 0
command_buffer_too_small => 0
connect_success => 0
connect_failure => 0
connection_reused => 0
reconnect => 0
pconnect_success => 0
active_connections => 0
active_persistent_connections => 0
explicit_close => 0
implicit_close => 0
disconnect_close => 0
in_middle_of_command_close => 0
explicit_free_result => 0
implicit_free_result => 0
explicit_stmt_close => 0
implicit_stmt_close => 0
mem_emalloc_count => 0
mem_emalloc_amount => 0
mem_ecalloc_count => 0
mem_ecalloc_amount => 0
mem_erealloc_count => 0
mem_erealloc_amount => 0
mem_efree_count => 0
mem_efree_amount => 0
mem_malloc_count => 0
mem_malloc_amount => 0
mem_calloc_count => 0
mem_calloc_amount => 0
mem_realloc_count => 0
mem_realloc_amount => 0
mem_free_count => 0
mem_free_amount => 0
mem_estrndup_count => 0
mem_strndup_count => 0
mem_estrdup_count => 0
mem_strdup_count => 0
mem_edupl_count => 0
mem_dupl_count => 0
proto_text_fetched_null => 0
proto_text_fetched_bit => 0
proto_text_fetched_tinyint => 0
proto_text_fetched_short => 0
proto_text_fetched_int24 => 0
proto_text_fetched_int => 0
proto_text_fetched_bigint => 0
proto_text_fetched_decimal => 0
proto_text_fetched_float => 0
proto_text_fetched_double => 0
proto_text_fetched_date => 0
proto_text_fetched_year => 0
proto_text_fetched_time => 0
proto_text_fetched_datetime => 0
proto_text_fetched_timestamp => 0
proto_text_fetched_string => 0
proto_text_fetched_blob => 0
proto_text_fetched_enum => 0
proto_text_fetched_set => 0
proto_text_fetched_geometry => 0
proto_text_fetched_other => 0
proto_binary_fetched_null => 0
proto_binary_fetched_bit => 0
proto_binary_fetched_tinyint => 0
proto_binary_fetched_short => 0
proto_binary_fetched_int24 => 0
proto_binary_fetched_int => 0
proto_binary_fetched_bigint => 0
proto_binary_fetched_decimal => 0
proto_binary_fetched_float => 0
proto_binary_fetched_double => 0
proto_binary_fetched_date => 0
proto_binary_fetched_year => 0
proto_binary_fetched_time => 0
proto_binary_fetched_datetime => 0
proto_binary_fetched_timestamp => 0
proto_binary_fetched_string => 0
proto_binary_fetched_json => 0
proto_binary_fetched_blob => 0
proto_binary_fetched_enum => 0
proto_binary_fetched_set => 0
proto_binary_fetched_geometry => 0
proto_binary_fetched_other => 0
init_command_executed_count => 0
init_command_failed_count => 0
com_quit => 0
com_init_db => 0
com_query => 0
com_field_list => 0
com_create_db => 0
com_drop_db => 0
com_refresh => 0
com_shutdown => 0
com_statistics => 0
com_process_info => 0
com_connect => 0
com_process_kill => 0
com_debug => 0
com_ping => 0
com_time => 0
com_delayed_insert => 0
com_change_user => 0
com_binlog_dump => 0
com_table_dump => 0
com_connect_out => 0
com_register_slave => 0
com_stmt_prepare => 0
com_stmt_execute => 0
com_stmt_send_long_data => 0
com_stmt_close => 0
com_stmt_reset => 0
com_stmt_set_option => 0
com_stmt_fetch => 0
com_deamon => 0
bytes_received_real_data_normal => 0
bytes_received_real_data_ps => 0
openssl
OpenSSL support => enabled
OpenSSL Library Version => OpenSSL 1.1.0j 20 Nov 2018
OpenSSL Header Version => OpenSSL 1.1.0j 20 Nov 2018
Openssl default config => /usr/lib/ssl/openssl.cnf
Directive => Local Value => Master Value
openssl.cafile => no value => no value
openssl.capath => no value => no value
pcre
PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 10.32 2018-09-10
PCRE Unicode Version => 11.0.0
PCRE JIT Support => enabled
PCRE JIT Target => x86 64bit (little endian + unaligned)
Directive => Local Value => Master Value
pcre.backtrack_limit => 1000000 => 1000000
pcre.jit => 1 => 1
pcre.recursion_limit => 100000 => 100000
PDO
PDO support => enabled
PDO drivers => sqlite, sqlsrv
pdo_sqlite
PDO Driver for SQLite 3.x => enabled
SQLite Library => 3.24.0
pdo_sqlsrv
pdo_sqlsrv support => enabled
ExtensionVer => 5.5.0-preview
Directive => Local Value => Master Value
pdo_sqlsrv.client_buffer_max_kb_size => 10240 => 10240
pdo_sqlsrv.log_severity => 0 => 0
Phar
Phar: PHP Archive support => enabled
Phar API version => 1.1.1
Phar-based phar archives => enabled
Tar-based phar archives => enabled
ZIP-based phar archives => enabled
gzip compression => enabled
bzip2 compression => disabled (install ext/bz2)
Native OpenSSL support => enabled
Phar based on pear/PHP_Archive, original concept by Davey Shafik.
Phar fully realized by Gregory Beaver and Marcus Boerger.
Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle.
Directive => Local Value => Master Value
phar.cache_list => no value => no value
phar.readonly => On => On
phar.require_hash => On => On
posix
POSIX support => enabled
readline
Readline Support => enabled
Readline library => EditLine wrapper
Directive => Local Value => Master Value
cli.pager => no value => no value
cli.prompt => \b \> => \b \>
Reflection
Reflection => enabled
session
Session Support => enabled
Registered save handlers => files user
Registered serializer handlers => php_serialize php php_binary
Directive => Local Value => Master Value
session.auto_start => Off => Off
session.cache_expire => 180 => 180
session.cache_limiter => nocache => nocache
session.cookie_domain => no value => no value
session.cookie_httponly => no value => no value
session.cookie_lifetime => 0 => 0
session.cookie_path => / => /
session.cookie_samesite => no value => no value
session.cookie_secure => 0 => 0
session.gc_divisor => 1000 => 1000
session.gc_maxlifetime => 1440 => 1440
session.gc_probability => 1 => 1
session.lazy_write => On => On
session.name => PHPSESSID => PHPSESSID
session.referer_check => no value => no value
session.save_handler => files => files
session.save_path => no value => no value
session.serialize_handler => php => php
session.sid_bits_per_character => 5 => 5
session.sid_length => 26 => 26
session.upload_progress.cleanup => On => On
session.upload_progress.enabled => On => On
session.upload_progress.freq => 1% => 1%
session.upload_progress.min_freq => 1 => 1
session.upload_progress.name => PHP_SESSION_UPLOAD_PROGRESS => PHP_SESSION_UPLOAD_PROGRESS
session.upload_progress.prefix => upload_progress_ => upload_progress_
session.use_cookies => 1 => 1
session.use_only_cookies => 1 => 1
session.use_strict_mode => 0 => 0
session.use_trans_sid => 0 => 0
SimpleXML
SimpleXML support => enabled
Schema support => enabled
sodium
sodium support => enabled
libsodium headers version => 1.0.11
libsodium library version => 1.0.11
SPL
SPL support => enabled
Interfaces => OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
Classes => AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, CallbackFilterIterator, DirectoryIterator, DomainException, EmptyIterator, FilesystemIterator, FilterIterator, GlobIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, MultipleIterator, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveCallbackFilterIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RecursiveRegexIterator, RecursiveTreeIterator, RegexIterator, RuntimeException, SplDoublyLinkedList, SplFileInfo, SplFileObject, SplFixedArray, SplHeap, SplMinHeap, SplMaxHeap, SplObjectStorage, SplPriorityQueue, SplQueue, SplStack, SplTempFileObject, UnderflowException, UnexpectedValueException
sqlite3
SQLite3 support => enabled
SQLite Library => 3.24.0
Directive => Local Value => Master Value
sqlite3.extension_dir => no value => no value
sqlsrv
sqlsrv support => enabled
ExtensionVer => 5.5.0-preview
Directive => Local Value => Master Value
sqlsrv.ClientBufferMaxKBSize => 10240 => 10240
sqlsrv.LogSeverity => 0 => 0
sqlsrv.LogSubsystems => 0 => 0
sqlsrv.WarningsReturnAsErrors => On => On
standard
Dynamic Library Support => enabled
Path to sendmail => -t -i
Directive => Local Value => Master Value
assert.active => 1 => 1
assert.bail => 0 => 0
assert.callback => no value => no value
assert.exception => 0 => 0
assert.quiet_eval => 0 => 0
assert.warning => 1 => 1
auto_detect_line_endings => 0 => 0
default_socket_timeout => 60 => 60
from => no value => no value
session.trans_sid_hosts => no value => no value
session.trans_sid_tags => a=href,area=href,frame=src,form= => a=href,area=href,frame=src,form=
url_rewriter.hosts => no value => no value
url_rewriter.tags => form= => form=
user_agent => no value => no value
tokenizer
Tokenizer Support => enabled
xml
XML Support => active
XML Namespace Support => active
libxml2 Version => 2.9.4
xmlreader
XMLReader => enabled
xmlwriter
XMLWriter => enabled
zlib
ZLib Support => enabled
Stream Wrapper => compress.zlib://
Stream Filter => zlib.inflate, zlib.deflate
Compiled Version => 1.2.8
Linked Version => 1.2.8
Directive => Local Value => Master Value
zlib.output_compression => Off => Off
zlib.output_compression_level => -1 => -1
zlib.output_handler => no value => no value
Additional Modules
Module Name
Environment
Variable => Value
SENDGRID_API_KEY => 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
TZ => America/New_York
php_vars => /usr/local/etc/php/conf.d/docker-vars.ini
HOSTNAME => 6e347f9b3dfb
PHPIZE_DEPS => autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2c
GPG_KEYS => CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D
SQL_PORT => 1433
SQL_HOST => db
TINI_VERSION => v0.18.0
PHP_ASC_URL => https://secure.php.net/get/php-7.3.1.tar.xz.asc/from/this/mirror
PHP_CFLAGS => -fstack-protector-strong -fpic -fpie -O2
ENV => local
SQL_USER => sa
PWD => /usr/src/app/src
HOME => /root
PHP_LDFLAGS => -Wl,-O1 -Wl,--hash-style=both -pie
PHP_INI_DIR => /usr/local/etc/php
PHP_URL => https://secure.php.net/get/php-7.3.1.tar.xz/from/this/mirror
PHP_CPPFLAGS => -fstack-protector-strong -fpic -fpie -O2
TERM => xterm
PHP_VERSION => 7.3.1
SHLVL => 1
PHP_MD5 =>
PATH => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SQL_DATABASE => ProEMS001
PHP_SHA256 => cfe93e40be0350cd53c4a579f52fe5d8faf9c6db047f650a4566a2276bf33362
SQL_PASSWORD => Tcdr9FFNRWXMkkERzUXcbecf
OLDPWD => /usr/src/app
_ => /usr/local/bin/php
PHP Variables
Variable => Value
$_SERVER['SENDGRID_API_KEY'] => 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
$_SERVER['TZ'] => America/New_York
$_SERVER['php_vars'] => /usr/local/etc/php/conf.d/docker-vars.ini
$_SERVER['HOSTNAME'] => 6e347f9b3dfb
$_SERVER['PHPIZE_DEPS'] => autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2c
$_SERVER['GPG_KEYS'] => CBAF69F173A0FEA4B537F470D66C9593118BCCB6 F38252826ACD957EF380D39F2F7956BC5DA04B5D
$_SERVER['SQL_PORT'] => 1433
$_SERVER['SQL_HOST'] => db
$_SERVER['TINI_VERSION'] => v0.18.0
$_SERVER['PHP_ASC_URL'] => https://secure.php.net/get/php-7.3.1.tar.xz.asc/from/this/mirror
$_SERVER['PHP_CFLAGS'] => -fstack-protector-strong -fpic -fpie -O2
$_SERVER['ENV'] => local
$_SERVER['SQL_USER'] => sa
$_SERVER['PWD'] => /usr/src/app/src
$_SERVER['HOME'] => /root
$_SERVER['PHP_LDFLAGS'] => -Wl,-O1 -Wl,--hash-style=both -pie
$_SERVER['PHP_INI_DIR'] => /usr/local/etc/php
$_SERVER['PHP_URL'] => https://secure.php.net/get/php-7.3.1.tar.xz/from/this/mirror
$_SERVER['PHP_CPPFLAGS'] => -fstack-protector-strong -fpic -fpie -O2
$_SERVER['TERM'] => xterm
$_SERVER['PHP_VERSION'] => 7.3.1
$_SERVER['SHLVL'] => 1
$_SERVER['PHP_MD5'] =>
$_SERVER['PATH'] => /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$_SERVER['SQL_DATABASE'] => ProEMS001
$_SERVER['PHP_SHA256'] => cfe93e40be0350cd53c4a579f52fe5d8faf9c6db047f650a4566a2276bf33362
$_SERVER['SQL_PASSWORD'] => Tcdr9FFNRWXMkkERzUXcbecf
$_SERVER['OLDPWD'] => /usr/src/app
$_SERVER['_'] => /usr/local/bin/php
$_SERVER['PHP_SELF'] =>
$_SERVER['SCRIPT_NAME'] =>
$_SERVER['SCRIPT_FILENAME'] =>
$_SERVER['PATH_TRANSLATED'] =>
$_SERVER['DOCUMENT_ROOT'] =>
$_SERVER['REQUEST_TIME_FLOAT'] => 1548363736.1565
$_SERVER['REQUEST_TIME'] => 1548363736
$_SERVER['argv'] => Array
(
)
$_SERVER['argc'] => 0
PHP License
This program is free software; you can redistribute it and/or modify
it under the terms of the PHP License as published by the PHP Group
and included in the distribution in the file: LICENSE
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
If you did not receive a copy of the PHP license, or have any
questions about PHP licensing, please contact license@php.net.
crunz.yml
# Crunz Configuration Settings
# This option defines where the task files and
# directories reside.
# The path is relative to the project's root directory,
# where the Crunz is installed (Trailing slashes will be ignored).
source: jobs
# The suffix is meant to target the task files inside the ":source" directory.
# Please note if you change this value, you need
# to make sure all the existing tasks files are renamed accordingly.
suffix: Tasks.php
# Timezone is used to calculate task run time
# This option is very important and not setting it is deprecated
# and will result in exception in 2.0 version.
timezone: UTC
# By default the errors are not logged by Crunz
# You may set the value to true for logging the errors
log_errors: true
# This is the absolute path to the errors' log file
# You need to make sure you have the required permission to write to this file though.
errors_log_file: php://stderr
# By default the output is not logged as they are redirected to the
# null output.
# Set this to true if you want to keep the outputs
log_output: true
# This is the absolute path to the global output log file
# The events which have dedicated log files (defined with them), won't be
# logged to this file though.
output_log_file: php://stdout
# By default line breaks in logs aren't allowed.
# Set the value to true to allow them.
log_allow_line_breaks: true
# This option determines whether the output should be emailed or not.
email_output: false
# This option determines whether the error messages should be emailed or not.
email_errors: false
# Global Swift Mailer settings
mailer:
# Possible values: smtp, mail, and sendmail
transport: smtp
recipients:
sender_name:
sender_email:
# SMTP settings
smtp:
host: ~
port: ~
username: ~
password: ~
encryption: ~
For a quick test I also just mocked the scheduler and am getting the correct output:
<?php
class Schedule
{
public function run($func)
{
$func();
return $this;
}
public function everyMinute()
{
return $this;
}
public function description()
{
return $this;
}
}
$schedule = new Schedule();
$x = 12;
$schedule->run(function () use ($x) {
echo "hi";
echo $x;
})
->everyMinute()
->description('Copying the project directory');
return $schedule;
root@84c44308ddca:/usr/src/app/src# vendor/bin/crunz schedule:run -vvv
Using config file /usr/src/app/src/crunz.yml.
Task source path '/usr/src/app/src/jobs'
Realpath for '/usr/src/app/src/jobs' is '/usr/src/app/src/jobs'
Task finder pattern '/usr/src/app/src/jobs/*Tasks.php'
Found 1 task(s) at path '/usr/src/app/src/jobs'
Timezone from config: 'UTC'.
Timezone for comparisons: 'UTC'.
hi12No event is due!
note the hi12 in the output.
On version v1.11.0
, task:
<?php
use Crunz\Schedule;
$x = 13;
$scheduler = new Schedule();
$scheduler
->run(function () use ($x) {
echo 'From lambda' . PHP_EOL;
echo 'Out: ' . $x . PHP_EOL;
})
->description('Lambda echo')
->everyMinute();
return $scheduler;
produces following log entry: [2019-01-25 15:25:51] crunz.INFO: Lambda echo(object(Closure)) From lambda Out: 13 [] []
. For me, everything works as expected.
Using the configuration I provided above and running your example I get the following output:
starting cron job daemon...
Using config file /usr/src/app/src/crunz.yml.
Task source path '/usr/src/app/src/jobs'
Realpath for '/usr/src/app/src/jobs' is '/usr/src/app/src/jobs'
Task finder pattern '/usr/src/app/src/jobs/*Tasks.php'
Found 1 task(s) at path '/usr/src/app/src/jobs'
Timezone from config: 'UTC'.
Timezone for comparisons: 'UTC'.
Invoke Schedule's ping before
There is no ping before url.
Invoke Event's ping before.
There is no ping before url.
Invoke Event's ping after.
There is no ping after url.
[2019-01-25 11:04:02] crunz.INFO: Lambda echo(object(Closure))
[] []
Task Lambda echo status: success.
Invoke Schedule's ping after.
There is no ping after url.
Interesting, for some reason you enabled loggin to file log_output: true
, but still redirect whole output to stdout output_log_file: php://stdout
, why?
Below configuration works for me:
log_output: true
output_log_file: crunz.log
Because it is a docker container so I want the logs to go to the container logging and not to a file on the container filesystem.
This is default behavior, there shouldn't be need to do tricks. Does it work with log_output: false
?
So what I know is that there is definitely a change in the project which introduces this issue. The exact same example (identical container and configuration) I provided above works fine if I revert to v1.10.0 (or earlier) but doesn't work after upgrading to v1.11.0. Is there any relevant change to how log output is captured by the crunz
scheduler between 1.10 and 1.11? Or possibly it's related to a change in a dependency resolution between 1.10 and 1.11?
log_output: false
produces no output at all...
Using config file /usr/src/app/src/crunz.yml.
Task source path '/usr/src/app/src/jobs'
Realpath for '/usr/src/app/src/jobs' is '/usr/src/app/src/jobs'
Task finder pattern '/usr/src/app/src/jobs/*Tasks.php'
Found 1 task(s) at path '/usr/src/app/src/jobs'
Timezone from config: 'UTC'.
Timezone for comparisons: 'UTC'.
Invoke Schedule's ping before
There is no ping before url.
Invoke Event's ping before.
There is no ping before url.
Invoke Event's ping after.
There is no ping after url.
Task Lambda echo status: success.
Invoke Schedule's ping after.
There is no ping after url.
On version v1.11.0
, in docker container and with config
log_output: true
output_log_file: php://stdout
everything works for me as expected. Here is my output:
[2019-01-26 06:25:32] crunz.INFO: Lambda echo(object(Closure)) From lambda Out: 13 [] []
[2019-01-26 06:25:32] crunz.INFO: PHP version(php -v) PHP 5.6.39 (cli) (built: Dec 21 2018 03:40:29) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies [] []
Could you create repository with code (including docker, Cron config, task, php config and all other configurations) to reproduce?
And to answer your questions:
Is there any relevant change to how log output is captured by the crunz scheduler between 1.10 and 1.11?
Yes and no. Now whole output (stdout
and stderr
) of command is captured. Theoretically you should see more output than previously :smiley:
Or possibly it's related to a change in a dependency resolution between 1.10 and 1.11?
Definitely no, monolog
was not touched.
@PabloKowalczyk https://github.com/esetnik/crunz-output is a minimum reproducible example. Hopefully it can help us get to the bottom of what's going on. One thing I noticed is that my container is using php:7.3-stretch
whereas yours is using php version 5.6.39.
In fact I tried using php:5.6-stretch
but the project doesn't even run...
❯ docker run -it crunz-output
starting cron job daemon...
Fatal error: Default value for parameters with a class type hint can only be NULL in /usr/src/app/src/vendor/symfony/console/Application.php on line 85
In fact it appears that symphony 4 requires php 7.1 https://symfony.com/doc/current/reference/requirements.html so i'm not sure how you managed to get crunz
working on php 5.6 unless you're using an older symphony version.
Finally found out what is going on, you are right, v1.11.0
broke running closures - path to Crunz bin was wrong.
Fixed and added E2E test, could you try this version https://github.com/PabloKowalczyk/crunz/tree/fix-closure-run?
Confirmed fixed in fix-closure-run although the project does not run on 5.6 only 7.1+. Do you want me to open a separate issue for this? It should be made note of in the documentation at least.
Crunz is 100% compatible with PHP 5.6 - https://travis-ci.org/lavary/crunz/jobs/484720655.
When you downgrade Symfony version you need to clear Crunz cache at /tmp/.crunz
.
Actually you are right about that. I was accidentally installing the project dependencies using 7.3 and then trying to use them in the 5.6 docker context. So this can be closed once your branch is merged.
Patch merged and released as v1.11.1
. Thanks @esetnik.
Example:
TestTasks.php
Output:
[2018-09-04 17:47:02] crunz.ERROR: Test schedule(object(Closure)) [] []