\r
bool KillCommand::DoExecute()\r
{\r
- GetShutdownServerNow().set_value(false); // False for not waiting until a key is pressed before terminating.\r
+ GetShutdownServerNow().set_value(false); // False for not attempting to restart.\r
+ return true;\r
+}\r
+\r
+bool RestartCommand::DoExecute()\r
+{\r
+ GetShutdownServerNow().set_value(true); // True for attempting to restart\r
return true;\r
}\r
\r
bool DoExecute();\r
};\r
\r
+class RestartCommand : public AMCPCommandBase<false, AddToQueue, 0>\r
+{\r
+ std::wstring print() const { return L"RestartCommand";}\r
+ bool DoExecute();\r
+};\r
+\r
} //namespace amcp\r
}} //namespace caspar\r
\r
// result = AMCPCommandPtr(new MonitorCommand());\r
//}\r
else if(s == TEXT("KILL")) return std::make_shared<KillCommand>();\r
+ else if(s == TEXT("RESTART")) return std::make_shared<RestartCommand>();\r
return nullptr;\r
}\r
\r
--- /dev/null
+@Echo off
+:Start
+casparcg.exe
+
+if ERRORLEVEL 5 goto :Start
}\r
} tbb_thread_installer;\r
\r
+ bool restart = false;\r
tbb::task_scheduler_init init;\r
\r
try \r
boost::property_tree::xml_writer_settings<wchar_t> w(' ', 3);\r
boost::property_tree::write_xml(str, caspar::env::properties(), w);\r
CASPAR_LOG(info) << L"casparcg.config:\n-----------------------------------------\n" << str.str().c_str() << L"-----------------------------------------";\r
- bool wait_for_keypress;\r
+ tbb::atomic<bool> wait_for_keypress;\r
+ wait_for_keypress = false;\r
\r
{\r
boost::promise<bool> shutdown_server_now;\r
\r
// Create server object which initializes channels, protocols and controllers.\r
caspar::server caspar_server(shutdown_server_now);\r
- \r
\r
// Use separate thread for the blocking console input, will be terminated \r
// anyway when the main thread terminates.\r
- boost::thread stdin_thread([&caspar_server, &shutdown_server_now]\r
+ boost::thread stdin_thread([&caspar_server, &shutdown_server_now, &wait_for_keypress]\r
{\r
// Create a amcp parser for console commands.\r
caspar::protocol::amcp::AMCPProtocolStrategy amcp(\r
\r
if(upper_cmd == L"EXIT" || upper_cmd == L"Q" || upper_cmd == L"QUIT" || upper_cmd == L"BYE")\r
{\r
- shutdown_server_now.set_value(true); // True to wait for keypress\r
+ wait_for_keypress = true;\r
+ shutdown_server_now.set_value(false); // False to not restart server\r
break;\r
}\r
\r
} \r
});\r
stdin_thread.detach();\r
- wait_for_keypress = shutdown_server.get();\r
+ restart = shutdown_server.get();\r
}\r
Sleep(500);\r
CASPAR_LOG(info) << "Successfully shutdown CasparCG Server.";\r
Sleep(4000);\r
} \r
\r
- return 0;\r
+ return restart ? 5 : 0;\r
}
\ No newline at end of file
<SubType>Designer</SubType>\r
</None>\r
<None Include="CasparCG.ico" />\r
+ <None Include="casparcg_auto_restart.bat" />\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="server.h" />\r
copy "$(SolutionDir)dependencies\zlib\*.dll" "$(OutDir)"\r
copy "$(SolutionDir)dependencies\SFML-1.6\lib\*.dll" "$(OutDir)"\r
copy "$(SolutionDir)dependencies\SFML-1.6\extlibs\bin\*.dll" "$(OutDir)"\r
-copy "$(ProjectDir)casparcg.config" "$(OutDir)"</Command>\r
+copy "$(ProjectDir)casparcg.config" "$(OutDir)"\r
+copy "$(ProjectDir)casparcg_auto_restart.bat" "$(OutDir)"</Command>\r
</PostBuildEvent>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
copy "$(SolutionDir)dependencies\zlib\*.dll" "$(OutDir)"\r
copy "$(SolutionDir)dependencies\SFML-1.6\lib\*.dll" "$(OutDir)"\r
copy "$(SolutionDir)dependencies\SFML-1.6\extlibs\bin\*.dll" "$(OutDir)"\r
-copy "$(ProjectDir)casparcg.config" "$(OutDir)"</Command>\r
+copy "$(ProjectDir)casparcg.config" "$(OutDir)"\r
+copy "$(ProjectDir)casparcg_auto_restart.bat" "$(OutDir)"</Command>\r
</PostBuildEvent>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">\r
copy "$(SolutionDir)dependencies\zlib\*.dll" "$(OutDir)"\r
copy "$(SolutionDir)dependencies\SFML-1.6\lib\*.dll" "$(OutDir)"\r
copy "$(SolutionDir)dependencies\SFML-1.6\extlibs\bin\*.dll" "$(OutDir)"\r
-copy "$(ProjectDir)casparcg.config" "$(OutDir)"</Command>\r
+copy "$(ProjectDir)casparcg.config" "$(OutDir)"\r
+copy "$(ProjectDir)casparcg_auto_restart.bat" "$(OutDir)"</Command>\r
</PostBuildEvent>\r
</ItemDefinitionGroup>\r
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Develop|Win32'">\r
copy "$(SolutionDir)dependencies\zlib\*.dll" "$(OutDir)"\r
copy "$(SolutionDir)dependencies\SFML-1.6\lib\*.dll" "$(OutDir)"\r
copy "$(SolutionDir)dependencies\SFML-1.6\extlibs\bin\*.dll" "$(OutDir)"\r
-copy "$(ProjectDir)casparcg.config" "$(OutDir)"</Command>\r
+copy "$(ProjectDir)casparcg.config" "$(OutDir)"\r
+copy "$(ProjectDir)casparcg_auto_restart.bat" "$(OutDir)"</Command>\r
</PostBuildEvent>\r
</ItemDefinitionGroup>\r
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
<ItemGroup>\r
<None Include="casparcg.config" />\r
<None Include="CasparCG.ico" />\r
+ <None Include="casparcg_auto_restart.bat" />\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="server.h">\r