sudo vim /etc/systemd/system/<servicename>.service
Shell
복사
Application
[Unit]
Description=foo/bar service
[Service]
Type=simple
EnvironmentFile=/opt/foobar/.env
ExecStart=/opt/foobar/app
WorkingDirectory=/opt/foobar
Restart=on-failure
StandardOutput=file:/var/log/foobar.log
StandardError=file:/var/log/foobar.log
[Install]
WantedBy=multi-user.target
Markdown
복사
Instance Restart / Terminate
[Unit]
Description=my_shutdown Service
Before=shutdown.target reboot.target halt.target
Requires=network-online.target network.target
[Service]
KillMode=none
ExecStart=/bin/true
ExecStop=/opt/scripts/terminate.sh
RemainAfterExit=yes
Type=oneshot
[Install]
WantedBy=multi-user.target
Markdown
복사
Start Daemon
systemctl daemon-reload
systemctl start servicename
systemctl status servicename
systemctl enable servicename
Shell
복사
