accomplice
Version, currently 0.1.05 versions
- 0.1.4latestJul 17, 2026
- 0.1.3not indexedJul 17, 2026
- 0.1.2not indexedJul 17, 2026
- 0.1.1not indexedJul 17, 2026
- 0.1.0not indexedJul 17, 2026
github.com/lachlan/crystal-accomplice
Allows any Crystal language program to easily run as a Windows Service with minimal change, and continue to support running as a console application.
Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
accomplice:
github: lachlan/crystal-accomplice
version: ~> 0.1.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
Accomplice
Allows any Crystal language program to easily run as a Windows Service with minimal change, while continuing to support running as a console application also.
Handles the Windows Service API for you. Adding Windows Service support is as
simple as adding the dependency on Accomplice to your shard.yml file, and
including a require "accomplice" line in your program before it does any
meaningful work.
Should you wish to add support for graceful shutdown, doing so requires minimal additional effort, either:
- Add
at_exithandlers to perform graceful shutdown tasks, or - Use
Process.on_terminateto register your own interrupt signal handler to perform graceful shutdown tasks and thenexit.
By default Accomplice waits 5 seconds for your program to gracefully shutdown, after which it forcibly stops the process.
You can also continue to run your program manually via the console after the above changes, without interference from Accomplice or the Windows Service API.
Note: a Windows Service necessarily requires at least two (2) threads, and this is accomplished using Crystal execution contexts as follows:
- the service dispatcher thread, started in an isolated execution context, and
- at least one other thread to run the actual service logic, the main thread.
Usage
-
Add the dependency to your
shard.yml:dependencies: accomplice: github: lachlan/crystal-accomplice -
Run
shards install -
Require
accomplicein your program, and then optionally include logic to gracefully shutdown your program when interrupted:
# Accomplice handles the Windows Service API for you, so that your
# program can be started and stopped by the Windows Service Control
# Manager (SCM).
#
# When you `require "accomplice"`, if the program was started by SCM
# then Accomplice will register the program as a Windows Service with
# SCM and set the status of the service to running.
#
# Otherwise if the program was started normally as a console
# application, Accomplice has no effect and your program runs normally
# as it always has before.
require "accomplice"
# Accomplice converts Windows Service Control Manager stop/shutdown
# controls to CTRL+C (SIGINT) interrupt signals to request the program
# to stop.
#
# Accomplice also includes a default interrupt signal handler which
# calls `exit`, allowing `at_exit` handlers to be used to gracefully
# shutdown:
at_exit {
# ...perform graceful shutdown tasks...
}
# OR you can replace the default interrupt signal handler with your
# own by using `Process.on_terminate` with a handler that stops your
# program gracefully and then exits:
Process.on_terminate do |reason|
Log.info { "SHUTDOWN INITIATED BY PROCESS TERMINATION, REASON = #{reason}" }
# ...perform graceful shutdown tasks...
exit
end
# Then run your program's logic as per normal:
loop do
# ...do stuff...
sleep 1.second
end
-
Compile:
shards build -
Create Windows service (note: these commands need to be run as an Administrator):
sc create <ServiceName> binpath= <ExecutablePath>
sc config <ServiceName> start= <boot|system|auto|demand|disabled|delayed-auto>
sc config <ServiceName> DisplayName= "<Service Display Name>"
sc description <ServiceName> "<Service Description>"
- Run Windows service
sc start <ServiceName>
...
sc stop <ServiceName>
Contributing
- Fork it (https://github.com/lachlan/crystal-accomplice/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Lachlan Dowding - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.0- Tagged
- Jul 17, 2026
- Commit
71f43d769327- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/lachlan/crystal-accomplice
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 15, 2026
- Versions
- 5