LoginSignup
1
0

systemdのunitファイル(service)でmiseを使う方法

Last updated at Posted at 2024-03-16

※完全に自分向けメモなので、解説は自分で探してください。

例: mise で管理している node で、MySpeed というサーバープロダクトを起動する方法

前提

  • mise のインストールは Quickstart に沿ったもの ($HOME/.local/bin/mise) ※ USER=pi
    • mise install node@20 済み
    • mise global ... は行っていない
  • MySpeed のインストール先は $HOME/myspeed/

.service ファイル

編集には systemctl edit を使うとよいでしょう。
(ref: systemdのUnitファイルのパスを知らなくともUnitファイルを編集する方法)

# apt autoremove --purge nano # (^q^)
systemctl --user edit --full --force myspeed.service
myspeed.service
[Unit]
Description = MySpeed

[Service]
WorkingDirectory = %h/myspeed
ExecStart = %h/.local/bin/mise exec node@20 -- node server
Restart = always
Environment= NODE_ENV=production

[Install]
WantedBy=default.target

設定方法

※今回はユーザーインスタンス(ユーザー権限でsystemdを動かす) 方法を取っています

systemd への登録

loginctl enable-linger $USER
systemctl --user enable --now myspeed.service

systemd から登録解除

systemctl --user disable --now myspeed.service

参考

EoT

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0