简体   繁体   中英

Planning to use nodejs in asp.net windows service(C#)

I am planning to see if I can use nodejs in an windows service( C#) project in any ways. I want to build a prototype which describes the usage of nodejs would be beneficial in some way in my project. I don't want to refactor or change the complete working code of my service, but instead i want to use nodejs as a learning gain with usage in my project.

I see most of the talk on net goes about usage of nodejs in some chat applications/ highly I/O operations.

Some inputs about my project which i could think of missing.Our current windows service-

  1. Doesn't have any UI
  2. Logs errors in the log files
  3. Keeps polling the database(oracle) for some work to do
  4. Doesn't have performance counters
  5. Doesn't have mail monitoring( like email sent out when any error occurs)

Can anyone suggest me where would nodejs would be helpful in the above ones? If not , why it isn't? Many Thanks In Advance,

This is a pretty open ended question, so I'll try to help with an open ended answer :)

First off - how to run nodejs code inside of a C# service. You probably want to take a look at edgejs: https://github.com/tjanczuk/edge

using System;
using System.Threading.Tasks;
using EdgeJs;

class Program
{
    public static async void Start()
    {
        var func = Edge.Func(@"
            return function (data, callback) {
                callback(null, 'Node.js welcomes ' + data);
            }
        ");

        Console.WriteLine(await func(".NET"));
    }

    static void Main(string[] args)
    {
        Task.Run((Action)Start).Wait();
    }
}

For logging - check out winston:

https://github.com/winstonjs/winston

And for perf counters, check this out:

https://www.npmjs.com/package/cwinperfcounter

Hopefully some of this helps. Happy Coding!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM