<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 18, 2017, at 12:57 AM, Emmanuel Bourreau &lt;<a href="mailto:ebourreau@nordnet.fr" class="">ebourreau@nordnet.fr</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Another question:<div class="">how can we use calendar server as a daemon on 10.11.6 ?</div><div class="">bin/run -d crashes but bin/run -n works. But the second one prevents my computer to switch off automatically at the end of the day.</div></div></div></blockquote><div><br class=""></div><div>bin/run isn't intended for installing or managing a service that people are actually using, it is just a developer convenience. Properly installing CalendarServer varies by platform, as does the recommended way to manage CalendarServer as a daemon. As you are on OS X, use a&nbsp;<a href="https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html#//apple_ref/doc/uid/10000172i-SW7-BCIEDDBJ" class="">launchd</a>&nbsp;plist to run the service as a daemon, something like:</div><div><br class=""></div><div>&lt;far too much time passes as I try to make this work&gt;</div><div><br class=""></div><div>This is actually really hard, or at least non-obvious, which is probably one of the reasons the documentation is so sparse. Some of the problems I've encountered along this path include:</div><span class=""><div class=""><br class=""></div><div class="">* you have to do the USE_OPENSSL=1 thing, because using keychain from a launchd daemon is a black art that shouldn't be attempted.<br class=""></div><div class=""><br class=""></div><div class="">* specifying a launchd job in the system domain (/Library/LaunchDaemons) configured to run as your personal account will likely not work. I can't get it to work, and I think it's due to something I&nbsp;don't know about launchd that's causing it to try to give the launched process access to my GUI session, or something. Specifying a user that is not logged in seems to work.<br class=""></div><div class=""><br class=""></div><div class="">* ./bin/package doesn't work on macOS. "/usr/bin/python2.7 -m virtualenv --system-site-packages --no-setuptools --always-copy ..." results in a bunch of permission denied errors. Removing the&nbsp;"--always-copy" option works around it, but I haven't thought through the possible implications. Ultimately this is caused by a macOS security feature called System Integrity Protection, which includes use of special file flags on apple-provides OS components. Some of these flags are not writable under normal circumstances, and shutil tries to preserve all flags, so it blows up.<br class=""></div><div class=""><br class=""></div><div class="">* After finally arriving at a ./bin/package'd installation at /Users/Shared/ccs, which I've chowned to the target user, I can't start it. Adding "set -x" to the top of bin/caldavd shows:<br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>exec /Users/Shared/ccs/bin/python '' --reactor=kqueue -n caldav -f /Users/Shared/ccs/conf/caldavd-dev.plist -o Twisted/reactor=kqueue<br class=""></div></span><span class="Apple-tab-span" style="white-space:pre">        </span>/Users/Shared/ccs/bin/python: can't find '__main__' module in ''<span class=""><br class=""></span><span class="">Eventually I realized this is because sourcing environment.sh (produced by ./bin/package) is not enough; one most also activate the virtualenv produced by ./bin/package (source virtualenv/bin/activate) prior to starting caldavd.</span></div><div><span class=""><br class=""></span></div><div><span class="">* Since bin/package produces no configs, so as a test (read: do not do this for real, developing a config file takes time and effort), I just copied the 'conf' directory from the project root into the dest dir produced by bin/package. Copy caldavd-test.plist to caldavd-dev.plist. Fish&nbsp;</span>twistedcaldav/test/data/server.pem out of the project directory and place it in your dest dir, and fix the path to server.pem in caldavd-dev.plist. Also create the 'data' directory at the top level of your dest dir.</div><div><br class=""></div><div>* Now it can, maybe, hopefully, actually start:</div><div><br class=""></div><div>/Users/Shared/ccs/bin/caldavd -X -R kqueue -f /Users/Shared/ccs/conf/caldavd-dev.plist -L</div><div><br class=""></div><div>Yes! works interactively.</div><div><br class=""></div><div>* But not via a launchd plist. It just exits with a status of '78' according to 'sudo launchctl list', which is not helpful. I have tried manually declaring PYTHONPATH and PATH as an environment var in the launchd.plist with what should be the right settings, but it still doesn't work.</div><div><br class=""></div><div>&lt;?xml version="1.0"&nbsp;encoding="UTF-8"?&gt;<br class="">&lt;!DOCTYPE&nbsp;plist&nbsp;PUBLIC&nbsp;"-//Apple//DTD PLIST 1.0//EN"&nbsp;"<a href="http://www.apple.com/DTDs/PropertyList-1.0.dtd" class="">http://www.apple.com/DTDs/PropertyList-1.0.dtd</a>"&gt;<br class="">&lt;plist&nbsp;version="1.0"&gt;<br class="">&lt;dict&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;key&gt;Label&lt;/key&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;string&gt;com.dre.calendarserver&lt;/string&gt;<br class=""><br class="">&nbsp; &nbsp;&nbsp;&lt;key&gt;EnvironmentVariables&lt;/key&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;dict&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;key&gt;PATH&lt;/key&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;string&gt;/Users/Shared/ccs/bin:/Users/Shared/ccs/virtualenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin&lt;/string&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;key&gt;PYTHONPATH&lt;/key&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;string&gt;/Users/Shared/ccs/virtualenv/lib/python27.zip:/Users/Shared/ccs/virtualenv/lib/python2.7:/Users/Shared/ccs/virtualenv/lib/python2.7/plat-darwin:/Users/Shared/ccs/virtualenv/lib/python2.7/plat-mac:/Users/Shared/ccs/virtualenv/lib/python2.7/plat-mac/lib-scriptpackages:/Users/Shared/ccs/virtualenv/lib/python2.7/lib-tk:/Users/Shared/ccs/virtualenv/lib/python2.7/lib-old:/Users/Shared/ccs/virtualenv/lib/python2.7/lib-dynload:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac:/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages:/Users/Shared/ccs/virtualenv/lib/python2.7/site-packages:/Users/Shared/ccs/virtualenv/src/twextpy:/Users/Shared/ccs/virtualenv/src/kerberos:/Users/Shared/ccs/virtualenv/src/pycalendar/src:/Users/Shared/ccs/virtualenv/src/caldavclientlibrary:/Users/Shared/ccs/virtualenv/src/caldavtester:/Users/Shared/ccs/virtualenv/lib/python2.7/site-packages/CalendarServer-9.1b1.dev0+a5933eaf63f5f3aef3b10949e70ecc0f5a49b736-py2.7.egg:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python:/Users/Shared/ccs/virtualenv/lib/python2.7/site-packages:/Library/Python/2.7/site-<a href="packages://Library/Frameworks/UIAutomation.framework/Versions/A/lib/python:/AppleInternal/Library/Python/2.7/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC&lt;/string&gt;" class="">packages://Library/Frameworks/UIAutomation.framework/Versions/A/lib/python:/AppleInternal/Library/Python/2.7/site-packages:/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC&lt;/string&gt;</a><br class="">&nbsp; &nbsp;&nbsp;&lt;/dict&gt;<br class=""><br class="">&nbsp; &nbsp;&nbsp;&lt;key&gt;WorkingDirectory&lt;/key&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;string&gt;/Users/Shared/ccs&lt;/string&gt;<br class=""><br class="">&nbsp; &nbsp;&nbsp;&lt;key&gt;ProgramArguments&lt;/key&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;array&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;string&gt;/Users/Shared/ccs/bin/caldavd&lt;/string&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;string&gt;-X&lt;/string&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;string&gt;-R&lt;/string&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;string&gt;kqueue&lt;/string&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;string&gt;-f&lt;/string&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;string&gt;/Users/Shared/ccs/conf/caldavd-dev.plist&lt;/string&gt;<br class="">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&lt;string&gt;-L&lt;/string&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;/array&gt;<br class=""><br class="">&nbsp; &nbsp;&nbsp;&lt;key&gt;UserName&lt;/key&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;string&gt;calendarz&lt;/string&gt;<br class=""><br class="">&nbsp; &nbsp;&nbsp;&lt;key&gt;GroupName&lt;/key&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;string&gt;calendarz&lt;/string&gt;<br class=""><br class="">&nbsp; &nbsp;&nbsp;&lt;key&gt;KeepAlive&lt;/key&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;true/&gt;<br class=""><br class="">&nbsp; &nbsp;&nbsp;&lt;key&gt;SessionCreate&lt;/key&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;false/&gt;<br class=""><br class="">&nbsp; &nbsp;&nbsp;&lt;key&gt;StandardOutPath&lt;/key&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;string&gt;/tmp/ccs.log&lt;/string&gt;<br class=""><br class="">&nbsp; &nbsp;&nbsp;&lt;key&gt;StandardErrorPath&lt;/key&gt;<br class="">&nbsp; &nbsp;&nbsp;&lt;string&gt;/tmp/ccs.log&lt;/string&gt;<br class=""><br class="">&lt;/dict&gt;<br class="">&lt;/plist&gt;</div><div><span class=""><br class=""></span></div><div><span class="">I have tried using a wrapper script that sources environment.sh and activates the virtualenv, and specifying that as the only ProgramArgument, but that fails the same way. I give up for now, and possibly forever. I recommend not using macOS for running CalendarServer. Sorry.</span></div><div><span class=""><br class=""></span></div><div><span class="">-dre<br class=""></span><span class=""><br class=""></span><span class=""></span><span class=""><br class=""></span><span class=""><blockquote type="cite" class=""><br class="">Console says python crashes<br class=""><br class="">here is the two lines:<br class="">18/02/2017 09:51:13,633 com.apple.xpc.launchd[1]: (com.apple.ReportCrash[3618]) Endpoint has been activated through legacy launch(3) APIs. Please switch to XPC or bootstrap_check_in():&nbsp;com.apple.ReportCrash<br class="">18/02/2017 09:51:13,993 ReportCrash[3618]: Saved crash report for python[3609] version 94 to /Users/emmanuel/Library/Logs/DiagnosticReports/python_2017-02-18-095113_Mac-Pro-de-Emmanuel.crash<br class=""><br class="">Is it SIP ?<br class=""><br class="">Emmanuel<br class=""><blockquote type="cite" class="">Le 18 févr. 2017 à 02:05, Andre LaBranche &lt;<a href="mailto:dre@apple.com" class="">dre@apple.com</a>&gt; a écrit :<br class=""><br class="">Hi,<br class=""><br class="">I'm not sure why a reboot fixed it, unless that somehow included rebuilding memcached. This could also be related to environmental changes like installing the Xcode CLI Tools (which are&nbsp;recommended). Research indicates this problem is similar to things we've seen when using the latest xcode on 10.11.6 without the CLI tools installed.<br class=""><br class="">-dre<br class=""><br class=""><blockquote type="cite" class="">On Feb 17, 2017, at 8:10 AM, Emmanuel Bourreau &lt;ebourreau@nordnet.fr&gt; wrote:<br class=""><br class="">Hello again,<br class="">I have restarted my computer and now it works.<br class="">Don’t know why…<br class="">Emmanuel<br class=""><blockquote type="cite" class="">Le 17 févr. 2017 à 11:08, Emmanuel Bourreau &lt;ebourreau@nordnet.fr&gt; a écrit :<br class=""><br class="">Hello<br class="">as usual, you’re right !<br class="">But I have another problem<br class="">After bin/run -n…<br class=""><br class="">Starting server...<br class="">Reading configuration from file: /Users/emmanuel/CalendarServer2/master/conf/caldavd-dev.plist<br class="">2017-02-17T10:51:17+0100 [twistedcaldav.upgrade#info] Converting augments.xml<br class="">2017-02-17T10:51:17+0100 [twistedcaldav.upgrade#info] Converting augments.xml<br class="">2017-02-17T10:51:17+0100 [calendarserver.tap.caldav.CalDAVServiceMaker#info] Calendar and Contacts Server 9.1b1.dev0+7c50b666693493196e6c3df59811063ef7368d97 starting Combined process...<br class="">2017-02-17T10:51:17+0100 [twistedcaldav.localization#info] Looking for Apple .lproj directories in locales<br class="">2017-02-17T10:51:17+0100 [twisted.scripts._twistd_unix.UnixAppLogger#info] twistd 16.6.0 (/Users/emmanuel/CalendarServer2/master/.develop/virtualenv/bin/python 2.7.10) starting up.<br class="">2017-02-17T10:51:17+0100 [twisted.scripts._twistd_unix.UnixAppLogger#info] reactor class: twisted.internet.selectreactor.SelectReactor.<br class="">2017-02-17T10:51:17+0100 [-] AMPPushNotifierFactory starting on 62311<br class="">2017-02-17T10:51:17+0100 [-] ControlSocket starting on './data/Logs/state/caldavd.sock'<br class="">2017-02-17T10:51:17+0100 [txdav.base.datastore.subpostgres#info] Cluster already exists at /Users/emmanuel/CalendarServer2/master/data/Data/Database/cluster<br class="">2017-02-17T10:51:17+0100 [txdav.base.datastore.subpostgres#info] Requesting postgres start via: ['/Users/emmanuel/CalendarServer2/master/.develop/roots/PostgreSQL/bin/pg_ctl', 'start', '--log=/Users/emmanuel/CalendarServer2/master/data/Logs/postgres.log', '--timeout=86400', '-w', '-o', "-c listen_addresses='' -c unix_socket_directories=/tmp/ccs_postgres_bfc609ea6b4ff8bf216572903d163531 -c&nbsp;shared_buffers=139 -c max_connections=93 -c standard_conforming_strings=on -c unix_socket_permissions=0770 -c log_line_prefix=%t"]<br class="">2017-02-17T10:51:17+0100 [memcached-Default] dyld: lazy symbol binding failed: Symbol not found: _clock_gettime<br class="">2017-02-17T10:51:17+0100 [memcached-Default] &nbsp; Referenced from: /Users/emmanuel/CalendarServer2/master/.develop/roots/libevent/lib/libevent-2.0.5.dylib (which was built for Mac OS X 10.12)<br class="">2017-02-17T10:51:17+0100 [memcached-Default] &nbsp; Expected in: /usr/lib/libSystem.B.dylib<br class="">2017-02-17T10:51:17+0100 [memcached-Default] dyld: Symbol not found: _clock_gettime<br class="">2017-02-17T10:51:17+0100 [memcached-Default] &nbsp; Referenced from: /Users/emmanuel/CalendarServer2/master/.develop/roots/libevent/lib/libevent-2.0.5.dylib (which was built for Mac OS X 10.12)<br class="">2017-02-17T10:51:17+0100 [memcached-Default] &nbsp; Expected in: /usr/lib/libSystem.B.dylib<br class="">2017-02-17T10:51:17+0100 [txdav.base.datastore.subpostgres.PostgresMonitor#info] waiting for server to start....<br class="">2017-02-17T10:51:18+0100 [txdav.base.datastore.subpostgres.PostgresMonitor#info] &nbsp;stopped waiting<br class="">2017-02-17T10:51:18+0100 [txdav.base.datastore.subpostgres.PostgresMonitor#error] pg_ctl: could not start server<br class="">2017-02-17T10:51:18+0100 [txdav.base.datastore.subpostgres.PostgresMonitor#error] Examine the log output.<br class="">2017-02-17T10:51:18+0100 [txdav.base.datastore.subpostgres.PostgresMonitor#info] pg_ctl process ended with status=256<br class="">2017-02-17T10:51:18+0100 [txdav.base.datastore.subpostgres.PostgresMonitor#error] Could not start postgres; see postgres.log<br class="">2017-02-17T10:51:18+0100 [txdav.base.datastore.subpostgres#critical] Can't start or connect to postgres: No such socket file: /tmp/ccs_postgres_bfc609ea6b4ff8bf216572903d163531/.s.PGSQL.5432<br class="">2017-02-17T10:51:18+0100 [-] (UNIX Port ./data/Logs/state/caldavd.sock Closed)<br class="">2017-02-17T10:51:18+0100 [-] (TCP Port 62311 Closed)<br class=""><br class="">And the server doesn’t start. Or I think so, because i can’t connect with Safari on localhost:8008 or 8443.<br class="">I remember I had same problem but can’t remember how i've solved it.<br class="">Furthermore : Is it a good idea to use bin/run -n at each startup of my computer ?<br class="">Thanks<br class="">Emmanuel<br class=""><br class=""><blockquote type="cite" class="">Le 17 févr. 2017 à 03:33, Andre LaBranche &lt;dre@apple.com&gt; a écrit :<br class=""><br class="">Hi,<br class=""><br class="">Try deleting the "localhost" cert from your keychain (using /Applications/Utilities/Keychain). I've seen this problem a few times but am still not sure exactly how it happens - possibly&nbsp;CalendarServer has lost access privs to a keychain item that was previously stashed there. Deleting will allow new items to be created.<br class=""><br class="">Alternatively, you can delete the .develop directory then "export USE_OPENSSL=1" and re-run bin/develop to disable use of SecureTransport, which includes disabling the use of keychain to&nbsp;store the server's private key.<br class=""><br class="">-dre<br class=""><br class="">On Feb 16, 2017, at 3:30 PM, Emmanuel Bourreau &lt;ebourreau@nordnet.fr&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">Hello,<br class="">during the bin/develop, i have the following error<br class="">Keychain init.<br class="">Could not find identity 'org.calendarserver.test'<br class="">Found certificate 'localhost'<br class="">Traceback (most recent call last):<br class="">&nbsp; File "bin/keychain_init.py", line 164, in &lt;module&gt;<br class="">&nbsp; &nbsp; identityCreate()<br class="">&nbsp; File "bin/keychain_init.py", line 67, in identityCreate<br class="">&nbsp; &nbsp; raise RuntimeError(error if error else output)<br class="">RuntimeError: security: No matching identity found for "localhost"<br class=""><br class="">Next, if i try a « bin/run -n »&nbsp;<br class="">i obtain<br class="">The configured TLS Keychain Identity (Keychain: org.calendarserver.test) cannot be used: Unable to load Keychain identity: org.calendarserver.test<br class=""><br class="">System : 10.11.6<br class=""><br class="">Calendarserver 9.1&nbsp;<br class=""><br class="">Can you help me ?<br class="">Thanks<br class="">Emmanuel<br class=""></blockquote><blockquote type="cite" class="">_______________________________________________<br class="">calendarserver-users mailing list<br class="">calendarserver-users@lists.macosforge.org<br class="">https://lists.macosforge.org/mailman/listinfo/calendarserver-users<br class=""></blockquote></blockquote><br class="">_______________________________________________<br class="">calendarserver-users mailing list<br class="">calendarserver-users@lists.macosforge.org<br class="">https://lists.macosforge.org/mailman/listinfo/calendarserver-users<br class=""></blockquote><br class=""></blockquote><br class=""></blockquote><br class=""></blockquote></span></div><span class=""><br class=""></span></div></body></html>