chatRooms
This commit is contained in:
parent
86130d2ee5
commit
871cf6b884
42 changed files with 15345 additions and 225 deletions
23
YaDaemon/OldYaDaemon.csproj
Executable file
23
YaDaemon/OldYaDaemon.csproj
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
<ReferenceInclude>PropertyGroup
|
||||
"Microsoft.AspNet.Hosting": "1.0.0-rc1-*",
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-*",
|
||||
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-*",
|
||||
"Microsoft.AspNet.Mvc": "6.0.0-rc1-*",
|
||||
"Microsoft.AspNet.Mvc.Core": "6.0.0-rc1-*",
|
||||
"Microsoft.AspNet.Http.Abstractions": "1.0.0-rc1-final",
|
||||
"Yavsc": {
|
||||
"type": "build",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
</PropertyGroup>
|
||||
-->
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,9 +1,87 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.ServiceProcess;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Hosting.Internal;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Framework.Configuration;
|
||||
using Microsoft.Framework.ConfigurationModel;
|
||||
using Yavsc;
|
||||
|
||||
class YaDaemon
|
||||
|
||||
public class Program : ServiceBase
|
||||
{
|
||||
static void Main(string[] args)
|
||||
private readonly EventLog _log =
|
||||
new EventLog("Application") { Source = "Application" };
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
private IHostingEngine _hostingEngine;
|
||||
private IDisposable _shutdownServerDisposable;
|
||||
private static Program instance;
|
||||
public Program(IServiceProvider serviceProvider)
|
||||
{
|
||||
Console.WriteLine("Hello World!");
|
||||
_serviceProvider = serviceProvider;
|
||||
instance = this;
|
||||
}
|
||||
// Fails claming "use mono-service" :
|
||||
// public static void Main(string[] args) => YaDaemon.YaDaemon.Main(args);
|
||||
public static void Main(string[] args) => YaDaemon.YaDaemon.Main(args);
|
||||
|
||||
// public static void Main(string[] args) => Console.WriteLine("Hello World!");
|
||||
|
||||
public void OldMain(string[] args)
|
||||
{
|
||||
Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment iappenv;
|
||||
IHostingEnvironment env = new Microsoft.AspNet.Hosting.HostingEnvironment();
|
||||
iappenv = null;// new HostingEnvironmentExtensions();
|
||||
Console.WriteLine("HW");
|
||||
|
||||
_log.WriteEntry("Test from MyDnxService.", EventLogEntryType.Information, 1);
|
||||
|
||||
|
||||
|
||||
#if DEBUG
|
||||
|
||||
OnStart(null);
|
||||
#else
|
||||
Run(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void OnStart(string[] args)
|
||||
{
|
||||
/* TODO how to use configSource
|
||||
var configSource = new MemoryConfigurationSource();
|
||||
configSource.Add("server.urls", "http://localhost:5000");
|
||||
configSource.Load();
|
||||
*/
|
||||
var configBuilder = new ConfigurationBuilder();
|
||||
configBuilder.AddInMemoryCollection();
|
||||
configBuilder.SetBasePath("../Yavsc/");
|
||||
configBuilder.AddJsonFile("../Yavsc/project.json");
|
||||
var config = configBuilder.Build();
|
||||
|
||||
var builder = new WebHostBuilder();
|
||||
|
||||
builder.UseServer("Microsoft.AspNet.Server.Kestrel");
|
||||
builder.UseServices(services => services.AddMvc());
|
||||
builder.UseStartup(appBuilder =>
|
||||
{
|
||||
appBuilder.UseDefaultFiles();
|
||||
appBuilder.UseStaticFiles();
|
||||
appBuilder.UseMvc();
|
||||
});
|
||||
|
||||
_hostingEngine = builder.Build();
|
||||
// Microsoft.AspNet.Hosting.WebApplication.Run<Startup>(args);
|
||||
|
||||
_shutdownServerDisposable = _hostingEngine.Start();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
13
YaDaemon/TestDaemonStart.cs
Normal file
13
YaDaemon/TestDaemonStart.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
namespace YaDaemon
|
||||
{
|
||||
using YaDaemon;
|
||||
|
||||
public class TestDaemonStart
|
||||
{
|
||||
public TestDaemonStart()
|
||||
{
|
||||
YaTaskScheduler shed = new YaTaskScheduler();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
3
YaDaemon/YaDaemon.csproj
Executable file → Normal file
3
YaDaemon/YaDaemon.csproj
Executable file → Normal file
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
95
YaDaemon/YaTaskScheduler.cs
Normal file
95
YaDaemon/YaTaskScheduler.cs
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace YaDaemon
|
||||
{
|
||||
public class YaTaskScheduler : TaskScheduler
|
||||
{
|
||||
List<Task> _tasks;
|
||||
|
||||
protected override IEnumerable<Task> GetScheduledTasks()
|
||||
{
|
||||
return _tasks;
|
||||
}
|
||||
|
||||
protected override void QueueTask(Task task)
|
||||
{
|
||||
_tasks.Add(task);
|
||||
}
|
||||
|
||||
protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued)
|
||||
{
|
||||
task.Start();
|
||||
task.Wait();
|
||||
return task.IsCompleted;
|
||||
}
|
||||
}
|
||||
public class YaDaemon: IDisposable
|
||||
{
|
||||
|
||||
private readonly EventLog _log =
|
||||
new EventLog("Application") { Source = "Application" };
|
||||
|
||||
async void MainLoop(string[] args)
|
||||
{
|
||||
|
||||
}
|
||||
public async static void Main(string[] args)
|
||||
{
|
||||
using (var prog = new YaDaemon()) {
|
||||
try {
|
||||
await prog.StartAsync(args);
|
||||
|
||||
} catch (Exception ex)
|
||||
{
|
||||
prog.OnContinue();
|
||||
}
|
||||
finally {
|
||||
prog.OnShutdown();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
async Task StartAsync(string[] args)
|
||||
{
|
||||
await Task.Run(() => {
|
||||
OnStart(args);
|
||||
} );
|
||||
}
|
||||
|
||||
protected void OnContinue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void OnShutdown()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void OnStart(string[] args)
|
||||
{
|
||||
_log.WriteEntry("Test from YaDaemon.", EventLogEntryType.Information, 1);
|
||||
_log.WriteEntry("YaDaemon started.");
|
||||
Console.WriteLine("YaDaemon started");
|
||||
}
|
||||
|
||||
protected void OnStop()
|
||||
{
|
||||
_log.WriteEntry("YaDaemon stopped.");
|
||||
Console.WriteLine("YaDaemon stopped");
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"sdk": {
|
||||
"version": "1.0.0-rc4-004771"
|
||||
}
|
||||
}
|
||||
17
YaDaemon/project.json
Normal file
17
YaDaemon/project.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
"description": "MyDnxService Console Application",
|
||||
"dependencies": {
|
||||
"Yavsc": {
|
||||
"type": "build",
|
||||
"version": "1.0.0"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": {
|
||||
"frameworkAssemblies": {
|
||||
"System.ServiceProcess": "4.0.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11722
YaDaemon/project.lock.json
Normal file
11722
YaDaemon/project.lock.json
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue