I have an EC2 WindowsServer2016 image with a scala project on it. I want it to start when I spin up an instance without me having to log in or do anything. I have a .bat
script with the following:
git pull
sbt run
In the TaskScheduler I created a task. Here is the XML.
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2017-07-19T10:34:17.5913961</Date>
<Author>EC2AMAZ-KLIVN0Q\Administrator</Author>
<URI>\StartServer</URI>
</RegistrationInfo>
<Triggers>
<BootTrigger>
<Enabled>true</Enabled>
</BootTrigger>
</Triggers>
<Principals>
<Principal id="Author">
<UserId>S-1-5-21-1707681336-2717460810-1492664229-500</UserId>
<LogonType>Password</LogonType>
<RunLevel>HighestAvailable</RunLevel>
</Principal>
</Principals>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<DisallowStartIfOnBatteries>false</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>true</UseUnifiedSchedulingEngine>
<WakeToRun>false</WakeToRun>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
<Priority>7</Priority>
</Settings>
<Actions Context="Author">
<Exec>
<Command>C:\Users\Administrator\cbf-render-server\run.bat</Command>
<WorkingDirectory>C:\Users\Administrator\cbf-render-server\</WorkingDirectory>
</Exec>
</Actions>
</Task>
PROBLEM: the server starts whenever I RDP into the machine. If I don't RDP into the machine it never seems to start. (I test whether it has started by curling the health endpoint).
I'm new to WindowsServer (UNIX background) could someone please tell me what I might be doing wrong?
Thanks