nextcloud / news-updater

:newspaper: Fast, parallel feed updater for the News app; written in Python
GNU General Public License v3.0
107 stars 24 forks source link

PHP Fatal error #7

Closed m-boyd closed 7 years ago

m-boyd commented 7 years ago

OS: QTS 4.3.2.0050 (QNAP official beta) PHP: 5.6.29 (cli) (OPKG) Nextcloud: 11.0.0 (QNAP Club)

[~] # nextcloud-news-updater --loglevel info /share/Web/nextcloud
2017-01-10 11:01:14,569 - Nextcloud News Updater - INFO - Running update in an interval of 900 seconds using 10 threads
2017-01-10 11:01:14,569 - Nextcloud News Updater - INFO - Running before update command: php -f /share/Web/nextcloud/occ news:updater:before-update
PHP Fatal error:  Allowed memory size of 8388608 bytes exhausted (tried to allocate 49152 bytes) in /share/CE_CACHEDEV1_DATA/.qpkg/NextCloud/nextcloud/lib/private/Files/View.php on line 1168
2017-01-10 11:01:16,433 - Nextcloud News Updater - ERROR - Command '['php', '-f', '/share/Web/nextcloud/occ', 'news:updater:before-update']' returned non-zero exit status 255: Trying again in 30 seconds
Traceback (most recent call last):
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/api/updater.py", line 69, in run
    self.before_update()
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/api/cli.py", line 73, in before_update
    self.cli.run(self.api.before_cleanup_command)
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/api/cli.py", line 12, in run
    return check_output(commands)
  File "/opt/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/opt/lib/python3.5/subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['php', '-f', '/share/Web/nextcloud/occ', 'news:updater:before-update']' returned non-zero exit status 255

Strange because memory_limit = 128M in php.ini. From here I terminated the process and received the following:

^CTraceback (most recent call last):
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/api/updater.py", line 69, in run
    self.before_update()
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/api/cli.py", line 73, in before_update
    self.cli.run(self.api.before_cleanup_command)
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/api/cli.py", line 12, in run
    return check_output(commands)
  File "/opt/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/opt/lib/python3.5/subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['php', '-f', '/share/Web/nextcloud/occ', 'news:updater:before-update']' returned non-zero exit status 255

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/nextcloud-news-updater", line 11, in <module>
    load_entry_point('nextcloud-news-updater==9.0.2', 'console_scripts', 'nextcloud-news-updater')()
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/__main__.py", line 26, in main
    container.resolve(Updater).run()
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/api/updater.py", line 99, in run
    time.sleep(30)
KeyboardInterrupt

Any assistance is appreciated!

BernhardPosselt commented 7 years ago

Please give your PHP more than 8 Mb of Memory ;)

You can do this in whatever php.ini is used for console commands (check your distro's documentation)

m-boyd commented 7 years ago

@BernhardPosselt I've checked memory limits in Apache web server (dependency for Nextcloud 11 from QNAP Club) as well as in the system web server and both are configured higher than 8 MB.

BernhardPosselt commented 7 years ago

Well the exception says that it tried to allocate memory above the maximum allowed value of 8 Mb. That's all I can tell you

m-boyd commented 7 years ago

Just realized that I should have been paying attention to the php.ini file in /opt/etc/. However, I now receive this error:

[~] # nextcloud-news-updater --loglevel info /share/Web/nextcloud
2017-01-10 11:55:14,163 - Nextcloud News Updater - INFO - Running update in an interval of 900 seconds using 10 threads
2017-01-10 11:55:14,163 - Nextcloud News Updater - INFO - Running before update command: php -f /share/Web/nextcloud/occ news:updater:before-update
2017-01-10 11:55:15,552 - Nextcloud News Updater - ERROR - Command '['php', '-f', '/share/Web/nextcloud/occ', 'news:updater:before-update']' returned non-zero exit status 1: Trying again in 30 seconds
Traceback (most recent call last):
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/api/updater.py", line 69, in run
    self.before_update()
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/api/cli.py", line 73, in before_update
    self.cli.run(self.api.before_cleanup_command)
  File "/opt/lib/python3.5/site-packages/nextcloud_news_updater/api/cli.py", line 12, in run
    return check_output(commands)
  File "/opt/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/opt/lib/python3.5/subprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['php', '-f', '/share/Web/nextcloud/occ', 'news:updater:before-update']' returned non-zero exit status 1

Any ideas?

BernhardPosselt commented 7 years ago

Check your logs and run the command manually:

['php', '-f', '/share/Web/nextcloud/occ', 'news:updater:before-update'] translates to

php -f /share/Web/nextcloud/occ news:updater:before-update
m-boyd commented 7 years ago
[~] # php -f /share/Web/nextcloud/occ news:updater:before-update
Console has to be executed with the user that owns the file config/config.php
Current user: admin
Owner of config.php: httpdusr
Try adding 'sudo -u httpdusr ' to the beginning of the command (without the single quotes)
[~] # sudo -u httpdusr php -f /share/Web/nextcloud/occ news:updater:before-update
{"reqId":"dL+5234\/Tt4X6PlvQhmx","remoteAddr":"","app":"no app in context","message":"Temporary directory \/opt\/tmp is not present or writable","level":2,"time":"2017-01-10T18:22:19+00:00","method":"--","url":"--","user":"--","version":"11.0.0.10”}
BernhardPosselt commented 7 years ago

Well here's your issue: Temporary directory \/opt\/tmp is not present or writable

BernhardPosselt commented 7 years ago

chown (try google)

m-boyd commented 7 years ago
[~] # chown -R httpdusr:administrators /opt/tmp/
[~] # sudo -u httpdusr nextcloud-news-updater /share/Web/nextcloud
BernhardPosselt commented 7 years ago

ok cool, now only run the updater using the same user and group

BernhardPosselt commented 7 years ago

Check the readme for a setup using systemd for instance