I am trying to set the iis 8.0 configuration preloadEnabled in my chef recipe, and i can't find the right combination of variables/attributes. I can't figure out how to specify the right application section as defined in the IIS docs, is the main problem.
I do already have ApplicationInitialization enabled, with this block, that i've visually confirmed on the server:
windows_feature 'IIS-ApplicationInit' do
action :install
end
I can open the applicationHost.config file listed in the iis docs, and i can see the app pools defined in there. But I can't seem to get my preloadEnabled attribute squeezed in there. This is the section I'm trying to access:
<system.applicationHost>
<sites>
<site name="MyApp" id="1">
<application path="/" applicationPool="ProdApp">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot" />
</application>
I'm trying to get the application section to look like this: <application path="/" preloadEnabled="true" applicationPool="ProdApp">
My current code is:
iis_config '"myAppPoolName" -section:system.applicationHost/applicationPools/sites/application/myAppPool/application /path="/" /preloadEnabled="true" /applicationPool="myAppPool" /commit:apphost'
After some more iterations and searching I've got this - still doesn't work:
'"MyApp" /path:"MyApp" /section:sites /preloadEnabled:true /commit:apphost'
(Answers to this could inform answers to this.)
Ok, i got it!
execute 'preloadEnabled' do
command 'c:\Windows\System32\inetsrv\appcmd.exe set app "MyApp/" /preloadEnabled:true'
end
Related
I'm new to NLog, and fighting with finding the solution to what I'm going for.
I'd like warning and up to get pushed to a slack channel with log level specific icons. I have got that working, technically. I have 2 pairs of targets/loggers that are hard coded to catch warnings only, and errors and above, and have 'warning' or 'error' icons hard coded into the layout template.
<target xsi:type="WebService"
name="slackWarningTarget"
url="https://hooks.slack.com/services/xx/xx/xx"
protocol="JsonPost"
encoding="utf-8"
>
<parameter name="text" type="System.String" layout=":warning: ${machinename} ${message}"/>
<parameter name="channel" type="System.String" layout="xx"/>
</target>
and
<logger name="*" minlevel="Warn" maxlevel="Warn" writeTo="slackWarningTarget">
Is there a way to better accomplish this? I want warning level to map to :warning:, etc.
I'd also like some info level stuff pushed there as well. To do this I created a named logger that always logs to the slack channel, but it results in duplicated messages if they are warning or above.
<logger name="noticeLogger" writeTo="slackInfoTarget" />
I'd guess there is a much more elegant way to do both of these things than i have come up with on my own.
You could do that from config with a ${when}, e.g.
layout="${when:when=${level}=='Warn':inner=\:warning\::else:${when:when=${level}== 'Error':inner=\:error\::else:todo}}"
but it get clumsy fast.
Another option is to register a custom layout renderer:
// register in the start of your program (e.g. main, app_start)
// usage ${slackIcon}
LayoutRenderer.Register("slackIcon", logEvent =>
{
if (logEvent.Level == LogLevel.Warn)
{
return ":warning:";
}
if (logEvent.Level == LogLevel.Error)
{
return ":error:";
}
return ":other:";
//etc
});
See How to write a custom layout renderer
Coming from a WPF background, I was trying to find a counterpart of GrammarBuilder (in System.Speech.Recognition) to implement choices, repeat and priorities in a Universal Windows app development. But it appears more things are different in Windows.Media.SpeechRecognition than I expected.
It appears Grammar is called Contraint in this Windows.Media.SpeechRecognition namespace, which makes sense. But as I look for the replacement for GrammarBuilder and SpeechRecognitionEngine.LoadGrammar, the closest Constraint I can find is SpeechRecognitionListConstraint. The MSDN documentation says there are Commands and Probability.
But, how can we add choices and repeats into the Commands (string[])? Something like:
var builder = new GrammarBuilder();
builder.Append("What is the", 0, 1);
builder.Append("forecast for ");
builder.Append(dayChoices, 0, 3);
or in SRGS
<rule id="forecast">
<item repeat="0-1">What is the</item>
<item>forecast for</item>
<item repeat="1-">
<one-of >
<item>Monday</item>
<item>Tuesday</item>
<item>Wednesday</item>
<item>Thursday</item>
<item>Friday</item>
<item>Saturday</item>
<item>Sunday</item>
</one-of>
</item>
</rule>
The example code in the demo app only has string[] as commands.
All JS I register with an id such as ++theme++mythemename/js/myscript.js gives me the following error on portal_javascripts: (resource not found or not accessible)
I know the id is correct because I can access localhost/mysite/++theme++mythemename/js/myscript.js (even if Diazo is disabled).
If development mode is on the resource gets delivered on the final HTML. However on production mode cooking process fails silently. Or almost. Besides getting a different cachekey than the one showed on portal_javascripts/manage_jsComposition, I see the following error message by accessing the cooked file:
/* XXX ERROR -- access to '++theme++mythemename/js/myscript.js' not authorized */
Any hints on how to deal with those? Or will I really need to leave them uncooked?
Have you tried a browser:resourceDirectory instead of a plone:static ?
<browser:resourceDirectory
name="yourJsFolder"
directory="yourJsFolder"
layer=".interfaces.IThemeSpecific"
/>
and calling your js with :
++resource++yourJsFolder/yourJsFile.js
i added your observatorio.tema package to an existing plone 4.1 buildout and added a random js file to the js registry (positioned after collapsibleformfields.js so it gets properly cooked)
GS export looks like:
<javascript authenticated="False" cacheable="True" compression="safe"
conditionalcomment="" cookable="True" enabled="True" expression=""
id="++theme++observatorio/js/ui.js" inline="False" insert-after="collapsibleformfields.js"/>
no error in portal_jacascripts and the javascript file is included in /jquery-cachekey-e7bee35d43da7a91eb29c6586dcbd396.js
did you add cacheable="False" and cookable="False" for testing purposes?
https://github.com/observatoriogenero/observatorio.tema/blob/master/src/observatorio/tema/profiles/default/jsregistry.xml#L373
since plone:static internally is a resourceDirectory both should and do work with resourceregistries.
maybe there is some other code in your buildout that re-registers another (empty) directory for the same name (observatorio)?
I'm implementing an ActiveSync Java client. I can already communicate with the server and perform the protocol sequence to Sync emails, as defined in the documentation.
However, when I try and send a Sync command it seems I can only use a subset of the available commands in the specification. When I use certain property tags in the Sync XML message I receive a Status 4 ('Protocol Error') code, even though these should be valid according to the specification.
When I use only the GetChanges property I do get a proper response, however I'd like to be able to specify how many items to return etc.
I've included the XML snippet that I'm sending: the commented out lines are lines that were attempted but caused a Status 4.
<?xml version="1.0" ?>
<Sync xmlns="AirSync:">
<Collections>
<Collection>
<Class>Email</Class>
<SyncKey>{23423972324}</SyncKey>
<CollectionId>{23423sdfsdfsdfsf972324}</CollectionId>
<GetChanges/>
<!--<GetChanges>0</GetChanges>-->
<!--<WindowSize>512</WindowSize>-->
<!--<Options>-->
<!--<Class>Email</Class>-->
<!--<FilterType>3</FilterType>-->
<!--<MaxItems>10</MaxItems>-->
<!--</Options>-->
<!--<Commands>-->
<!-- <Fetch>-->
<!-- <ServerId>1:323</ServerId>-->
<!-- </Fetch>-->
<!--</Commands>-->
</Collection>
</Collections>
<!--<WindowSize>512</WindowSize>-->
</Sync>
Is there any reason why these properties shouldn't be supported? Or is there something I've left out of the message?
The GetOptions command for the server returns the following (truncated):
Server: Microsoft-IIS/6.0,
X-Powered-By: ASP.NET,
Pragma: no-cache,
Public: OPTIONS, POST, Allow: OPTIONS, POST,
MS-Server-ActiveSync: 6.5.7653.19,
MS-ASProtocolVersions: 1.0,2.0,2.1,2.5,
MS-ASProtocolCommands:Sync,SendMail,SmartForward,SmartReply,GetAttachment,GetHierarchy,CreateCollection,DeleteCollection,MoveCollection,FolderSync,FolderCreate,FolderDelete,FolderUpdate,MoveItems,GetItemEstimate,MeetingResponse,ResolveRecipients,ValidateCert,Provision,Search,Notify,Ping
It turns out that the WBXML encode/decoder I was using wasn't working correctly. I figured this out by comparing the byte code generated by two different WBXML encoders and saw a difference. The encoder I was using didn't process empty elements like properly. I fixed it and now the server acts as expected.
I've tried to set 1column template for home page using my local.xml file:
<cms_index_index>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
</reference>
</cms_index_index>
But this is doesn't work. How can I do this?
Homepage is a CMS page. Unfortunately, you can't assign root template for CMS pages using layout, because they have own attribute "root_template" (cms_page table).
You can change this attribute in the backend (CMS - Pages).
Or you can change it in code:
$homePage = Mage::getModel('cms/page')->load('home', 'identifier');
$homePage->setRootTemplate('one_column');
$homePage->save();
I recommend you to write sql data upgrade, which will update root template value for homepage:
$installer = $this;
/* #var $installer Mage_Core_Model_Resource_Setup */
$installer->startSetup();
$installer->run("
UPDATE `{$this->getTable('cms_page')}` SET `root_template` = 'one_column' WHERE `identifier` = 'home';
");
$installer->endSetup();
I'm sure the other suggestions work well, but that all looks way too complicated to me. What I've done which seems to work great, is to simply put the following into the Layout Update XML for the CMS page in question (in this case, your home page)
<reference name="root">
<action method="setTemplate">
<template>page/1column.phtml</template>
</action>
</reference>
The problem lays in Mage_Cms_Helper_Page::_renderPage. Layout updates are applied -before- root template (configured from the backend) is applied:
Mage::dispatchEvent('cms_page_render', array('page' => $page, 'controller_action' => $action));
$action->loadLayoutUpdates();
$layoutUpdate = ($page->getCustomLayoutUpdateXml() && $inRange) ? $page->getCustomLayoutUpdateXml() : $page->getLayoutUpdateXml();
$action->getLayout()->getUpdate()->addUpdate($layoutUpdate);
$action->generateLayoutXml()->generateLayoutBlocks();
...
if ($page->getRootTemplate()) {
$action->getLayout()->helper('page/layout')
->applyTemplate($page->getRootTemplate());
}
Also notice how the only event in this method is inconveniently placed above all of this... Should you want to fix this cleanly (without queries), you should observe the following event:
controller_action_postdispatch_cms_index_index
Then do the following (untested, but should work):
$this->getEvent()->getControllerAction()->getLayout()->helper('page/layout')->applyTemplate('one_column');
Then render the layout again. This is all just a guideline how to solve this through observers.