Linux/centos2018. 12. 3. 17:13

_

2019.03.21

centos7 기준 아래 경로가 잘못되어 수정

# vi /usr/lib/systemd/system/servicename




# vi /usr/lib/systemd/service/servicename

[Unit]

Description = making network connection up

After = network.target


[Service]

ExecStart = /root/scripts/conup.sh


[Install]

WantedBy = multi-user.target


실제 서비스 등록

# chmod +x /root/scripts/conup.sh

# systemctl enable servicename  


[링크 : https://www.tecmint.com/create-new-service-units-in-systemd/]



+

node.js 경로줘서 실행하기


npm start --prefix path/to/your/app 


[링크 : https://stackoverflow.com/questions/36172442/how-to-npm-start-at-a-different-directory]


+

귀찮으니.. whereis로 찾아서

/bin/http-server 와(얘는 걍 스크립트)

/bin/node 를 만들어 주면 해결!(얘는 바이너리)

[링크 : http://leechwin.tistory.com/...usrbinenv-node-No-such-file-or-directory-에러가-발생하는-경우]



+

reload를 적용하려면 아래의 줄을 [service] 항목에 추가하면 되는 듯?

[Unit]

Description=The NGINX HTTP and reverse proxy server

After=syslog.target network.target remote-fs.target nss-lookup.target


[Service]

Type=forking

PIDFile=/run/nginx.pid

ExecStartPre=/usr/sbin/nginx -t

ExecStart=/usr/sbin/nginx

ExecReload=/bin/kill -s HUP $MAINPID

ExecStop=/bin/kill -s QUIT $MAINPID

PrivateTmp=true


[Install]

WantedBy=multi-user.target 


[링크 : https://www.shellhacks.com/systemd-service-file-example/]

Posted by 구차니