topshelf - an easy service hosting framework for building windows services using .net
TRANSCRIPT
![Page 1: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/1.jpg)
TOPSHELF - AN EASY SERVICE HOSTING FRAMEWORK FOR
BUILDING WINDOWS SERVICES USING .NET
Larry Nung
![Page 2: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/2.jpg)
AGENDAIntroductionGetting startedCustom ServiceCommand-LineReferenceQ & A
2
![Page 3: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/3.jpg)
INTRODUCTION3
![Page 4: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/4.jpg)
INTRODUCTION Put Your Apps on the Topshelf An easy service hosting framework for
building Windows services using .NET
4
![Page 5: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/5.jpg)
GETTING STARTED5
![Page 6: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/6.jpg)
GETTING STARTED
6
![Page 7: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/7.jpg)
GETTING STARTED
7
![Page 8: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/8.jpg)
GETTING STARTEDusing System; using Topshelf;…class Program { static void Main(string[] args) { HostFactory.Run(x => { x.Service<Program>(s => { s.ConstructUsing(name => new Program()); s.WhenStarted(p => p.Start()); s.WhenStopped(p => p.Stop()); }); }); }
public void Start() { Console.WriteLine("Service start..."); }
public void Stop() { Console.WriteLine("Service stop..."); }}
8
![Page 9: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/9.jpg)
GETTING STARTED
9
![Page 10: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/10.jpg)
CUSTOM SERVICE10
![Page 11: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/11.jpg)
CUSTOM SERVICEusing System; using Topshelf;... class Program { static void Main(string[] args) { HostFactory.Run(x => { x.Service<ProgramService>(); }); } } class ProgramService : ServiceControl { public bool Start(HostControl hostControl) { Console.WriteLine("Service start..."); return true; } public bool Stop(HostControl hostControl) { Console.WriteLine("Service stop..."); return true; } } ...
11
![Page 12: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/12.jpg)
COMMAND-LINE12
![Page 13: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/13.jpg)
COMMAND-LINE service.exe [verb] [-option:value] [-switch]
run Runs the service from the command line (default) help, --help Displays help install Installs the service
--autostart The service should start automatically (default) --disabled The service should be set to disabled --manual The service should be started manually --delayed The service should start automatically (delayed) -instance An instance name if registering the service multiple times -username The username to run the service -password The password for the specified username --localsystem Run the service with the local system account --localservice Run the service with the local service account --networkservice Run the service with the network service permission --interactive The service will prompt the user at installation for the service credentials
13
![Page 14: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/14.jpg)
COMMAND-LINEstart Start the service after it has been installed --sudo Prompts for UAC if running on Vista/W7/2008
-servicename The name that the service should use when installing -description The service description the service should use when installing -displayname The display name the the service should use when installing
start Starts the service if it is not already running stop Stops the service if it is running
uninstall Uninstalls the service
-instance An instance name if registering the service multiple times --sudo Prompts for UAC if running on Vista/W7/2008
14
![Page 15: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/15.jpg)
COMMAND-LINEExamples:
service install Installs the service into the service control manager
service install -username:joe -password:bob --autostart Installs the service using the specified username/password and configures the service to start automatically at machine startup
service uninstall Uninstalls the service
service install -instance:001 Installs the service, appending the instance name to the service
name so that the service can be installed multiple times. You may need to tweak the log4net.config to make this play nicely with the log files.
15
![Page 16: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/16.jpg)
COMMAND-LINE
16
![Page 17: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/17.jpg)
COMMAND-LINE
17
![Page 18: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/18.jpg)
COMMAND-LINE
18
![Page 19: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/19.jpg)
COMMAND-LINE
19
![Page 20: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/20.jpg)
COMMAND-LINE
20
![Page 21: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/21.jpg)
COMMAND-LINE
21
![Page 22: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/22.jpg)
REFERENCE22
![Page 23: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/23.jpg)
REFERENCE Topshelf
http://topshelf-project.com/
Welcome to Topshelf’s documentation! — Topshelf 3.0 documentation https://
topshelf.readthedocs.io/en/latest/index.html
Topshelf/Topshelf: An easy service hosting framework for building Windows services using .NET https://github.com/Topshelf/Topshelf
23
![Page 24: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/24.jpg)
Q&A24
![Page 25: Topshelf - An easy service hosting framework for building Windows services using .NET](https://reader031.vdocuments.mx/reader031/viewer/2022030223/5882267a1a28ab52368b5125/html5/thumbnails/25.jpg)
QUESTION & ANSWER
25