Closed Lacrul closed 9 years ago
In older versions of NCache there was also a configuration key inside "Alachisoft.NCache.Service.exe.config" named "
Named: add key="NCacheServer.AutoStartCache" value="mycache,myreplicatedcache"
Auto-Start feature is not available in Open source edition of NCache
Auto-Start feature is available only in Enterprise edition. Feature comparison is available here
Since it's opensource, we just need to see how startcache.exe does it. Then modify the service to look for the auto-start tag and auto start it. Seems easy enough so not sure why Ncache bothered ripping it out of the opensource. But instead of tracing through all that and branching from the master source I just created a scheduled task. The task triggers off of the windows event once the service starts, then it runs the startcache.exe for my specified cache. Works great for me. Here's the XML you guys can import as a scheduled task. Be sure to modify any paths and cache name as needed before importing. I'm on win server 2008r2 so not sure if this will work on other OS.
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.3" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2015-04-29T16:15:28.9383844</Date>
<Author>SYSTEM</Author>
<Description>Start the cache once ncache service starts since opensource version doesn't support auto-start. https://github.com/Alachisoft/NCache/issues/1</Description>
</RegistrationInfo>
<Triggers>
<EventTrigger>
<Enabled>true</Enabled>
<Subscription><QueryList><Query Id="0" Path="Application"><Select Path="Application">*[System[Provider[@Name='NCacheSvc'] and (Level=4 or Level=0) and (EventID=0)]] and *[EventData[Data='Service started successfully.']]</Select></Query></QueryList></Subscription>
</EventTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-18</UserId>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
<StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
<AllowHardTerminate>true</AllowHardTerminate>
<StartWhenAvailable>false</StartWhenAvailable>
<RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
<IdleSettings>
<StopOnIdleEnd>true</StopOnIdleEnd>
<RestartOnIdle>false</RestartOnIdle>
</IdleSettings>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<Hidden>false</Hidden>
<RunOnlyIfIdle>false</RunOnlyIfIdle>
<DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
<UseUnifiedSchedulingEngine>false</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>P3D</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>cmd</Command>
<Arguments>/c "c:\program files\ncache\bin\tools\startcache.exe" mycachename</Arguments>
</Exec>
</Actions>
</Task>
There is an Auto-Start features for caches that is also documented and inside the samples to start caches on Service restart. It is a tag that can be added to cache-config in the "config.ncconf"-file. The feature does not work! I can't also find it anywhere inside the source code. So it looks like it was removed, but this must be an accident. Maybe someone can tell about that?