Code Monkey home page Code Monkey logo

cake.services's Introduction

Cake.Services

Cake-Build addin that extends Cake with windows service commands

Build status

cakebuild.net

Join the chat at https://gitter.im/cake-build/cake

Table of contents

  1. Implemented functionality
  2. Referencing
  3. Usage
  4. Example
  5. Plays well with
  6. License
  7. Share the love

Implemented functionality

  • Start
  • Stop
  • Restart
  • Pause
  • Continue
  • Execute Command
  • Get Service
  • Get Status
  • Install
  • Uninstall
  • Manage remote services

Referencing

NuGet Version NuGet Downloads

Cake.Services is available as a nuget package from the package manager console:

Install-Package Cake.Services

or directly in your build script via a cake addin directive:

#addin "Cake.Services"

Usage

#addin "Cake.Services"

Task("Start-Service")
    .Description("Start a stopped windows service")
    .Does(() =>
{
    StartService("MpsSvc");
});

Task("Stop-Service")
    .Description("Stop a running windows service")
    .Does(() =>
{
    StopService("MpsSvc", "remote-location");
});

Task("Restart-Service")
    .Description("Restart a running windows service")
    .Does(() =>
{
    RestartService("MpsSvc");
});


Task("Pause-Service")
    .Description("Pause a running windows service")
    .Does(() =>
{
    PauseService("MpsSvc");
});

Task("Continue-Service")
    .Description("Continue a paused windows service")
    .Does(() =>
{
    ContinueService("MpsSvc", "remote-location");
});

Task("Execute-Command")
    .Description("Execute a command on a running service")
    .Does(() =>
{
    ExecuteServiceCommand("MyService", 4);
});


Task("Get-Service")
    .Description("Get a windows service object installed on a machine")
    .Does(() =>
{
    ServiceController controller = GetService("MpsSvc", "remote-location");

    if (controller != null)
    {
        controller.Stop();
    }
});

Task("Is-Service-Running")
    .Description("Check if a windows service is running")
    .Does(() =>
{
    bool status = IsServiceRunning("MpsSvc");

    if (status)
    {
        Debug("YAY!");
    }
});

Task("Is-Service-Stopped")
    .Description("Check if a windows service is stopped")
    .Does(() =>
{
    bool status = IsServiceStopped("MpsSvc");

    if (status)
    {
        Debug("YAY!");
    }
});


Task("Install-Service")
    .Description("Install a windows service")
    .Does(() =>
{
    InstallService("remote-location", new InstallSettings()
    {
        ServiceName = "Popup",
        DisplayName = "Annoying popup",
        Description = "Displays adds every time you move the mouse",

        ExecutablePath = "C:/LOL/Popup.exe",
        StartMode = "auto",

        Username = "Admin",
        Password = "pass1"
    });
});

Task("Uninstall-Service")
    .Description("Uninstall a windows service")
    .Does(() =>
{
    UninstallService("Popup", "remote-location");
});

RunTarget("Start-Service");

Example

A complete Cake example can be found here.

TroubleShooting

  • Please be aware of the breaking changes that occurred with the release of Cake v0.22.0, you will need to upgrade Cake in order to use Cake.Services v0.3.0 or above.

Plays well with

If your looking to manage Topshelf windows services its worth checking out Cake.Topshelf.

If your looking for a way to trigger cake tasks based on windows events or at scheduled intervals then check out CakeBoss.

License

Copyright (c) 2015 - 2016 Phillip Sharpe

Cake.Services is provided as-is under the MIT license. For more information see LICENSE.

Share the love

If this project helps you in anyway then please โญ the repository.

cake.services's People

Contributors

brian6peng avatar matneyx avatar nelsonwellswku avatar sharperad avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.