Skip to content

fusuma.service for local development

Kohei Yamada edited this page Jul 14, 2024 · 1 revision

Fusuma Service for Development

This document provides a guide to set up and manage a Fusuma service specifically for development purposes using systemd user services. Fusuma is installed using rbenv and local plugins are loaded via a specified Gemfile.

Setup Steps

1. Register fusuma.service

Create the necessary directory and fusuma.service file, then enable the service:

$ mkdir -p ~/.config/systemd/user/
$ vim ~/.config/systemd/user/fusuma.service # Copy the provided content below
$ systemctl --user enable fusuma.service

2. Reload and Restart fusuma.service

Reload the systemd daemon and restart the service:

$ systemctl --user daemon-reload && systemctl --user restart fusuma.service

3. Check Logs

Monitor the service logs to ensure it is running correctly:

$ journalctl --user -u fusuma.service -f

4. Unregister fusuma.service

To disable and remove the fusuma.service, follow these steps:

$ systemctl --user disable fusuma.service
$ systemctl --user daemon-reload
$ rm ~/.config/systemd/user/fusuma.service

fusuma.service File Content

Below is the content for the fusuma.service file:

[Unit]
Description=Fusuma for development
After=default.target

[Service]
# Use bundler (bundler is installed in ~/.rbenv/shims with rbenv)
ExecStart=%h/.rbenv/shims/bundle exec fusuma --verbose
# Directory where Gemfile is located
WorkingDirectory=%h/.ghq/github.com/iberianpig/fusuma/
# Specify BUNDLE_GEMFILE for customized Gemfile
Environment="BUNDLE_GEMFILE=Gemfile.local"

[Install]
WantedBy=default.target
Explanation of the Configuration
  • [Unit]

    • Description: Brief description of the service.
    • After: Ensures the service starts after the default.target.
  • [Service]

    • ExecStart: Command to start Fusuma using bundler (bundler is managed by rbenv and located in ~/.rbenv/shims).
    • WorkingDirectory: Path to the directory where the Gemfile is located.
    • Environment: Specifies the custom Gemfile.local.
  • [Install]

    • WantedBy: Ensures the service is started in the default target.

This configuration ensures that Fusuma runs as a systemd user service, utilizing rbenv for Ruby environment management and a local Gemfile for plugin customization. This guide is specifically tailored for developers setting up Fusuma in a development environment.

Example Gemfile.local

Here is an example of a Gemfile.local that can be used to load local plugins for Fusuma:

Click to expand `Gemfile.local` example
source "https://rubygems.org"

# Specify your gem's dependencies in fusuma.gemspec
gemspec

gem "bump"
gem "bundler"
gem "github_changelog_generator", "~> 1.16"
gem "debug"
gem 'rdbg'
gem "rake", "~> 13.0"
gem "rblineprof"
gem "rblineprof-report"
gem "reek"
gem "rspec", "~> 3.0"
gem "rspec-debug"
gem "rspec-parameterized"
gem "rubocop"
gem "simplecov"
gem "standard", require: false
gem "yard"

gem "attractor"
gem "attractor-ruby"

# additional
gem "solargraph"

# fusuma plugins for local development
[
  "iberianpig/fusuma-plugin-sendkey",
  "iberianpig/fusuma-plugin-wmctrl",
  "iberianpig/fusuma-plugin-keypress",
  "iberianpig/fusuma-plugin-appmatcher",
  "iberianpig/fusuma-plugin-remap",
  "iberianpig/fusuma-plugin-thumbsense"
].each do |repo|
  name = repo.split("/").last
  gem name, path: "~/.ghq/github.com/#{repo}" # Load local plugins from specified path
end