こちらのサンプルを systemd で起動するようにしました。
Nest.js と TypeORM で MariaDB に接続
設定ファイルの作成
/etc/systemd/system/one_shot.service
[Unit]
Description=one_shot shell
After=netctl@profile.service
[Service]
Environment=NODE_PORT=3000
Type=simple
User=www-data
Restart=on-failure
WorkingDirectory=/home/uchida/nest/sample/05-sql-typeorm
ExecStart=npm start
[Install]
WantedBy=multi-user.target
起動
sudo systemctl start one_shot
状態の確認
$ sudo systemctl status one_shot
● one_shot.service - one_shot shell
Loaded: loaded (/etc/systemd/system/one_shot.service; disabled; vendor pre>
Active: active (running) since Fri 2021-02-12 13:03:33 JST; 42s ago
Main PID: 92839 (node)
Tasks: 35 (limit: 1064)
Memory: 258.4M
CGroup: /system.slice/one_shot.service