update_daemon wont run on OS X Server

Support requests, bug reports, etc. go here. Dedicated servers / VDS hosting only
Filius
Bear Rating Trainee
Bear Rating Trainee
Posts: 2
Joined: 20 Mar 2010, 19:02

update_daemon wont run on OS X Server

Postby Filius » 20 Mar 2010, 19:05

Hi,

I recently moved my tt-rss installation from Linux to OS X Server 10.6.2. The database move went smooth, but the update_daemon wont run. Whenever I start it I get this error:

Code: Select all

PHP Notice:  Constant MAGPIE_CACHE_AGE already defined in /Users/stian/Sites/private/tt-rss/functions.php on line 111
PHP Notice:  Undefined variable: err_msg in /Users/stian/Sites/private/tt-rss/sanity_check.php on line 82
PHP Fatal error:  Call to undefined function pcntl_signal() in /Users/stian/Sites/private/tt-rss/update_daemon.php on line 47


The php version is the one shipped with the system. I have tried googleing and searching these forums, but cant seem to find a solution :(

Anyone have any idea?

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: update_daemon wont run on OS X Server

Postby fox » 21 Mar 2010, 12:08

You can safely comment the pcntl_signal() out and it should work afterwards. It's weird that PHP on OS X is build without pcntl functions, though.

To add: this would work for the regular update daemon. The forking one (update_daemon2.php) requires pcntl stuff to work properly.

Tarul
Bear Rating Trainee
Bear Rating Trainee
Posts: 4
Joined: 21 Mar 2010, 13:17

Re: update_daemon wont run on OS X Server

Postby Tarul » 21 Mar 2010, 22:23

Hello Filius,
I have the same problem on mac os x server. but i propose this workaround.
I use the update_feeds php file with launchd (as crontad daemon).
Go to on /Library/LaunchDaemons
edit an plist file (example with textmate).

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Debug</key>
<true/>
   <key>GroupName</key>
   <string>admin</string>
   <key>Label</key>
   <string>org.ttrss.update_feeds</string>
   <key>ProgramArguments</key>
   <array>
      <string>/usr/bin/php</string>
      <string>/Volumes/Macintosh HD2/ServiceData/Web/Documents/tt-rss/update_feeds.php</string>
   </array>
   <key>RunAtLoad</key>
   <true/>
   <key>StandardErrorPath</key>
   <string>/var/log/ttrss_update_feed_err.log</string>
   <key>StandardOutPath</key>
   <string>/var/log/ttrss_update_feed.log</string>
   <key>StartInterval</key>
   <integer>900</integer>
   <key>UserName</key>
   <string>root</string>
   <key>WorkingDirectory</key>
   <string>/Volumes/Macintosh HD2/ServiceData/Web/Documents/tt-rss/</string>
</dict>
</plist>

I use options UserName and GroupName because my tt-rss directory has owner the admin group and root user. These options work only if you use sudo in launchtcl command line. With this file, the update_feeds is launched every 900 seconds with root user.

To launch this daemon, you use the launchctl command :

Code: Select all

sudo launchctl  load /Library/LaunchDaemons/org.ttrss.update_feeds.plist

To check the daemon is worked, you can check the console.app if the script file work (no exit code 1), or if the file /var/log/ttrss_update_feed(_err).log is updated.

Filius
Bear Rating Trainee
Bear Rating Trainee
Posts: 2
Joined: 20 Mar 2010, 19:02

Re: update_daemon wont run on OS X Server

Postby Filius » 22 Mar 2010, 10:11

Tarul, thank you!

I didnt even think about that solution! It works perfectly, and is imo much more elegant than running update_daemon in screen. You saved my day! (also thanks to fox for beeing head-man, and providing a workaround ^_^)

Im a happy camper!

Cheers!

User avatar
fox
^ me reading your posts ^
Posts: 6318
Joined: 27 Aug 2005, 22:53
Location: Saint-Petersburg, Russia
Contact:

Re: update_daemon wont run on OS X Server

Postby fox » 22 Mar 2010, 11:12

I'll add function_exists() there so you wouldn't need the workaround in the future. Nice thinking to use launchd on OS X, by the way. I'll link this topic from the FAQ. :)

Tarul
Bear Rating Trainee
Bear Rating Trainee
Posts: 4
Joined: 21 Mar 2010, 13:17

Re: update_daemon wont run on OS X Server

Postby Tarul » 06 Jan 2011, 00:54

Hello everybody,

This is an update about my previous post. It's necessery with the 1.5.0 version.

To begin, update /Library/LaunchDaemons/org.ttrss.update_feeds.plist

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Debug</key>
<true/>
   <key>GroupName</key>
   <string>admin</string>
   <key>Label</key>
   <string>org.ttrss.update_feeds</string>
   <key>ProgramArguments</key>
   <array>
      <string>/usr/bin/php</string>
      <string>/Volumes/Macintosh HD2/ServiceData/Web/Documents/tt-rss/update.php</string>
      <string>-feeds</string>
   </array>
   <key>RunAtLoad</key>
   <true/>
   <key>StandardErrorPath</key>
   <string>/var/log/ttrss_update_feed_err.log</string>
   <key>StandardOutPath</key>
   <string>/var/log/ttrss_update_feed.log</string>
   <key>StartInterval</key>
   <integer>900</integer>
   <key>UserName</key>
   <string>root</string>
   <key>WorkingDirectory</key>
   <string>/Volumes/Macintosh HD2/ServiceData/Web/Documents/tt-rss/</string>
</dict>
</plist>


and tape followed commands :

Code: Select all

sudo launchctl  unload /Library/LaunchDaemons/org.ttrss.update_feeds.plist

Code: Select all

sudo launchctl  load /Library/LaunchDaemons/org.ttrss.update_feeds.plist


see you later.

XianPalin
Bear Rating Trainee
Bear Rating Trainee
Posts: 21
Joined: 16 May 2013, 23:10

Re: update_daemon wont run on OS X Server

Postby XianPalin » 20 May 2013, 18:55

I just wanted to post a reply to this as I had to make some modifications to get this working on 1.7.9, and this was really the only post I could find that talked about launchd.

The main change is that in the plist file, it should be --feeds instead of -feeds (i.e. two dashes instead of one). It wasn't logging any error with only one dash, but it also wasn't updating the feeds.

The second change needed is to not use sudo when executing the launchctl command. If you use sudo, the ttrss update script spits back an error saying not to run it as superuser.

I believe those changes are all you need to get it working with 1.7.9. I'm running on OS X 10.8.2. Hopefully this will help someone else that is using a Mac and wants to automatically refresh their feeds, as the update page seems more geared towards Linux installs.

BLOGfile
Bear Rating Trainee
Bear Rating Trainee
Posts: 3
Joined: 07 Apr 2014, 00:50

Re: update_daemon wont run on OS X Server

Postby BLOGfile » 07 Apr 2014, 01:47

Here is a .plist for running the actual daemon.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>GroupName</key>
   <string>admin</string>
   <key>UserName</key>
   <string>YOURUSERNAMEHERE</string>
   <key>Debug</key>
   <true/>
   <key>Label</key>
   <string>ttrss.feeds_updated</string>
   <key>ProgramArguments</key>
   <array>
      <string>YOUR/PATH/TO/ttrss/update.php</string>
      <string>--daemon</string>
   </array>
   <key>StandardErrorPath</key>
   <string>/var/log/ttrss_update_feed_err.log</string>
   <key>StandardOutPath</key>
   <string>/var/log/ttrss_update_feed.log</string>
   <key>RunAtLoad</key>
   <true/>
   <key>AbandonProcessGroup</key>
   <true/>
</dict>
</plist>


So for this to work on OS X you can to put the code text in a text file save with the file name ttrss.feeds_updated.plist Move it to /System/Library/LaunchAgents Go to the get info tab for LaunchAgents scroll down to the Sharing & Permissions tab, click the Gear and click Apply to enclosed items... That will make it readable to launchd

The .plist needs to have the same name as the label string in this case ttrss.feeds_updated.plist YOURUSERNAMEHERE should be your admin username. YOUR/PATH/TO/ttrss/update.php needs to be changed to the actual path to the file. It will load on every reboot you can load it yourself
with

Code: Select all

launchctl load /System/Library/LaunchAgents/ttrss.feeds_updated.plist
and you can check if its loaded with

Code: Select all

launchctl list

shannonp
Bear Rating Trainee
Bear Rating Trainee
Posts: 12
Joined: 12 Apr 2013, 04:42

Re: update_daemon wont run on OS X Server

Postby shannonp » 07 Apr 2014, 03:03

The ideal place to put this custom launchd plist file is /Library/LaunchDaemons as per Apple's guidelines.

Typically LaunchAgents are per-user whereas LaunchDaemons are system-wide. /System/Library are for system only items, custom items should reside in /Library. Putting items into the wrong location may be removed if a system update is performed. Refer to "man launchd" or Apple's Developer Documentation for more info.

Shannon

BLOGfile
Bear Rating Trainee
Bear Rating Trainee
Posts: 3
Joined: 07 Apr 2014, 00:50

Re: update_daemon wont run on OS X Server

Postby BLOGfile » 07 Apr 2014, 03:30

shannonp wrote:The ideal place to put this custom launchd plist file is /Library/LaunchDaemons as per Apple's guidelines.

Typically LaunchAgents are per-user whereas LaunchDaemons are system-wide. /System/Library are for system only items, custom items should reside in /Library. Putting items into the wrong location may be removed if a system update is performed. Refer to "man launchd" or Apple's Developer Documentation for more info.

Shannon


The LaunchDaemons folder is designed to not interact with users so it won't work in that folder. There is a launchagents and launchdaemons folder in each users library and that wouldn't be a good place for this but the system/library/launchagents is really the only place to do what the ttrss daemon needs as it can't be run in the root context.

shannonp
Bear Rating Trainee
Bear Rating Trainee
Posts: 12
Joined: 12 Apr 2013, 04:42

Re: update_daemon wont run on OS X Server

Postby shannonp » 07 Apr 2014, 05:14

I have to disagree there. I have mine setup as I mentioned and it's been working fine since day 1. I have all my custom services (MySQL, MythTV etc etc) setup the same and everything starts up at boot time as Apple advise.

Shannon

shannonp
Bear Rating Trainee
Bear Rating Trainee
Posts: 12
Joined: 12 Apr 2013, 04:42

Re: update_daemon wont run on OS X Server

Postby shannonp » 07 Apr 2014, 05:43

FWIW, here's my plist file (unmodified). The file name is "org.tt-rss.update-feeds.plist"...

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
   <key>Label</key>
   <string>org.tt-rss.update-feeds</string>
   <key>ProgramArguments</key>
   <array>
      <string>/usr/bin/php</string>
      <string>/Library/Server/Web/Data/Sites/Default/tt-rss/update.php</string>
      <string>--daemon</string>
   </array>
   <key>WorkingDirectory</key>
   <string>/Library/Server/Web/Data/Sites/Default/tt-rss/</string>
   <key>UserName</key>
   <string>serveradmin</string>
   <key>GroupName</key>
   <string>_www</string>
   <key>RunAtLoad</key>
   <true/>
   <key>StandardErrorPath</key>
   <string>/var/log/tt-rss/error.log</string>
   <key>StandardOutPath</key>
   <string>/var/log/tt-rss/update-feeds.log</string>
</dict>
</plist>


Shannon

BLOGfile
Bear Rating Trainee
Bear Rating Trainee
Posts: 3
Joined: 07 Apr 2014, 00:50

Re: update_daemon wont run on OS X Server

Postby BLOGfile » 07 Apr 2014, 06:41

Ok anyways it does work if I put it in /Library/LaunchDaemons I was tripped up by some documentation in the man pages
Any and all work that involves interacting with a user should be done through agents.
but it works none the less with out having to log in. thanks shannonp!

gigAcEj
Bear Rating Trainee
Bear Rating Trainee
Posts: 1
Joined: 07 Apr 2014, 23:47

Re: update_daemon wont run on OS X Server

Postby gigAcEj » 08 Apr 2014, 00:00

I have been running tt-rss for more than a year with the plist update file in ~/Library/LaunchAgents, so update is running as an ordinary user. The dB on the backend is postgresql 9.2.4, with php55, both installed from mac homebrew. This is plain OS X 10.9.2, the non-server version. Running php as root is asking for trouble, IMHO. Here is my org.tt-rss.update.plist. I am using the stock apache that comes with OS X, with the tt-rss install living in /Library/WebServer/Documents/tt-rss. The database files are in /usr/local/var/postgres.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>org.tt-rss.update</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>UserName</key>
    <string>bob</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/php</string>
        <string>/Library/Webserver/Documents/tt-rss/update.php</string>
        <string>--daemon</string>
    </array>
    <key>WorkingDirectory</key>
    <string>/Users/bob</string>
  </dict>
</plist>

shannonp
Bear Rating Trainee
Bear Rating Trainee
Posts: 12
Joined: 12 Apr 2013, 04:42

Re: update_daemon wont run on OS X Server

Postby shannonp » 08 Apr 2014, 02:52

This would be another way to do it as long as a user is logged in. As I run the Server version of OSX 10.9 I don't want to have that restriction. You could also apply the same theory to a non-Server version of the OS, just tweak the plist and pop it into /Library/LaunchDaemons.

My php isn't running as root as you'll see by the plist file. Check out "man launchd.plist" for more info on running system-level launchd items as other users. Also looking at BLOGfile's plist, that has the same "UserName" key as mine so it may not be run as root either.

Shannon


Return to “Support”

Who is online

Users browsing this forum: Google [Bot] and 5 guests