Alachisoft / NCache

NCache: Highly Scalable Distributed Cache for .NET
http://www.alachisoft.com
Apache License 2.0
647 stars 123 forks source link

Auto-Start feature does not work in Open-Source Version #1

Closed Lacrul closed 9 years ago

Lacrul commented 9 years ago

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?

Lacrul commented 9 years ago

In older versions of NCache there was also a configuration key inside "Alachisoft.NCache.Service.exe.config" named "". Than it was switched to the Auto-Start-Tag-Style. But this "older" configuration key does not work either.

Lacrul commented 9 years ago

Named: add key="NCacheServer.AutoStartCache" value="mycache,myreplicatedcache"

NCacheDev commented 9 years ago

Auto-Start feature is not available in Open source edition of NCache

NCacheDev commented 9 years ago

Auto-Start feature is available only in Enterprise edition. Feature comparison is available here

eeldivad commented 9 years ago

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>&lt;QueryList&gt;&lt;Query Id="0" Path="Application"&gt;&lt;Select Path="Application"&gt;*[System[Provider[@Name='NCacheSvc'] and (Level=4 or Level=0) and (EventID=0)]] and *[EventData[Data='Service started successfully.']]&lt;/Select&gt;&lt;/Query&gt;&lt;/QueryList&gt;</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>
mokth commented 5 years ago

for the task aboive (by eeldivad) replace /c "c:\program files\ncache\bin\tools\startcache.exe" mycachename with "start-cache mycachename"

actually u can run start-cache mycachename at cmd line.