Skip to content

Commit

Permalink
Merge pull request #15 from chwebdude/build-osx
Browse files Browse the repository at this point in the history
Added OS X Bootstrap to start application with one click instead to open Terminal
  • Loading branch information
chwebdude authored Jan 14, 2018
2 parents cde8c99 + b53fc00 commit 4a7142d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 8 deletions.
9 changes: 7 additions & 2 deletions CryptoManager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using NLog;
using NLog.Web;

namespace CryptoManager
Expand All @@ -15,10 +16,14 @@ public class Program
{
public static void Main(string[] args)
{
var logger = NLogBuilder.ConfigureNLog("NLog.config").GetCurrentClassLogger();
var rootPath = Directory.GetCurrentDirectory();
var nlogConfig = Path.Combine(rootPath, "NLog.config");
NLogBuilder.ConfigureNLog(nlogConfig);
var logger = LogManager.GetCurrentClassLogger();

try
{
logger.Debug("init main");
logger.Debug("Start Webhost");
BuildWebHost(args).Run();
}
catch (Exception e)
Expand Down
12 changes: 9 additions & 3 deletions CryptoManager/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ public Startup(IConfiguration configuration)

public IConfiguration Configuration { get; }


// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
var rootPath = Directory.GetCurrentDirectory();
var parent = Directory.GetParent(rootPath);
var dataDir = Path.Combine(parent.FullName, "data");
CryptoContext.DatabaseFile = Path.Combine(dataDir, "crypto.db");

services.AddMvc();
Directory.CreateDirectory("../data");
var connection = "Data Source = ../data/crypto.db";
Directory.CreateDirectory(dataDir);
var connection = "Data Source = '" + CryptoContext.DatabaseFile + "'";
services.AddDbContext<CryptoContext>(options => options.UseSqlite(connection));

// Add some Swag
Expand Down Expand Up @@ -94,7 +100,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
// Enable Hangfire
app.UseHangfireDashboard();
app.UseHangfireServer();


// Enable middleware to serve generated Swagger as a JSON endpoint.
app.UseSwagger();
Expand Down
3 changes: 2 additions & 1 deletion Model/CryptoContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ namespace CryptoManager.Models
public class CryptoContext : DbContext
{
public CryptoContext(DbContextOptions<CryptoContext> options) : base(options) { }
public static string DatabaseFile;

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Data Source=../data/crypto.db");
optionsBuilder.UseSqlite("Data Source='" + CryptoContext.DatabaseFile + "'");
}

public DbSet<CryptoTransaction> Transactions { get; set; }
Expand Down
2 changes: 0 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
version: '{build}'
pull_requests:
do_not_increment_build_number: true
image: Visual Studio 2017 Preview
clone_depth: 1
init:
Expand Down
5 changes: 5 additions & 0 deletions docs/RunScripts/CryptoManagerBootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#/bin/bash
echo Starting CryptoManager
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"
./CryptoManager
12 changes: 12 additions & 0 deletions docs/RunScripts/StartCryptoManager
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#/bin/bash
echo Starting CryptoManager
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"
cd bin/
open ./CryptoManagerBootstrap
echo "Wait for Startup..."
sleep 7
open http://localhost:5000
echo "You can close this window now"
exit 0

0 comments on commit 4a7142d

Please sign in to comment.