public static void Main(string[] args)
{
#if __MonoCS__
Environment.SetEnvironmentVariable("MONO_MANAGED_WATCHER", "enabled");
Environment.SetEnvironmentVariable("MONO_XMLSERIALIZER_THS", "no");
#endif
Controller = new Controller();
// Custom configuration file specified from command line.
if (args.Length > 0)
{
ConfigManager.CurrentConfigFile = args[0];
}
bool firstRun = !File.Exists(ConfigManager.CurrentConfigFile);
ServicePointManager.CertificatePolicy = new CertPolicyHandler();
// Migrate config.xml from past versions, if necessary.
if (!firstRun)
{
ConfigMigration.Migrate();
}
CmisSync.Lib.Utils.ConfigureLogging();
Logger.Info("Starting. Version: " + CmisSync.Lib.Backend.Version);
if (args.Length != 0 && !args[0].Equals("start") &&
Backend.Platform != PlatformID.MacOSX &&
Backend.Platform != PlatformID.Win32NT)
{
string n = Environment.NewLine;
Console.WriteLine(n +
"CmisSync is a collaboration and sharing tool that is" + n +
"designed to keep things simple and to stay out of your way." + n +
n +
"Version: " + CmisSync.Lib.Backend.Version + n +
"Copyright (C) 2014 Aegif" + n +
"This program comes with ABSOLUTELY NO WARRANTY." + n +
n +
"This is free software, and you are welcome to redistribute it" + n +
"under certain conditions. Please read the GNU GPLv3 for details." + n +
n +
"Usage: CmisSync [start|stop|restart]");
Environment.Exit(-1);
}
// Only allow one instance of CmisSync (on Windows)
if (args.Length == 0 && // Allow more than one instance if using a custom config file.
!program_mutex.WaitOne(0, false))
{
Logger.Error("CmisSync is already running.");
Environment.Exit(-1);
}
// Increase the number of concurrent requests to each server,
// as an unsatisfying workaround until this DotCMIS bug 632 is solved.
// See https://github.com/aegif/CmisSync/issues/140
ServicePointManager.DefaultConnectionLimit = 1000;
try
{
Controller.Initialize(firstRun);
UI = new GUI();
UI.Run();
}
catch (Exception e)
{
Logger.Fatal("Exception in Program.Main", e);
Environment.Exit(-1);
}
#if !__MonoCS__
//// Suppress assertion messages in debug mode
//GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
//GC.WaitForPendingFinalizers();
#endif
}