Synology Nas ºÎÆýà ÀÚµ¿ ½ÇÇà ÇÁ·Î±×·¥ µî·Ï

   Á¶È¸ 14646   Ãßõ 2    

출처: http://majikshoe.blogspot.kr/2014/12/starting-service-on-synology-dsm-5.html

영문내용이지만 관심 있으신 분 있을까 싶어서 올립니다.

DSM에 포함되어 있는 Upstart tool을 이용한 부팅시 실행 스크립트 등록 법이라고 하네요.


Synology NAS - How to make a program run at startup

The other day I created a little node.js project to keep track of some finances. Synology has a node.js package but that just installs the tools - it has no 'container' or any other support to drop files and have it run automagically. Maybe one day.


In the meantime, you can start your project when you SSH into the NAS. My project has a 'www' script which bootstraps my project, so to start I simply type 'node bin/www' from the project directory. But, it only runs while I'm logged in, and if I log out for any reason, the process dies. That's hardly useful when I'm away from home, or on a different PC. So I decided to have a look at starting my project as a Linux service.


After doing a lot of research into how Synology does services, and a few failed attempts at init scripts, I found that Synology DSM (since version 5 perhaps) bundles Upstart, which is a neat little tool to deal with services on Linux. It's most prevalent on Debian and derivatives (notably Ubuntu). So, here's how I got my node.js application running on startup by using Upstart.


Step 1. Create an Upstart script.


Upstart scripts live in /etc/init by default, and that's also the place they live on your Synology NAS. You name the script 'servicename.conf', where 'servicename' is whatever you want it to be called. I called mine 'foobar' because I'm inventive like that, so the file is /etc/init/foobar.conf.


You can be as simple or as comprehensive as you like. I started by using a very simple script, like the one below.



# only start this service after the httpd user process has started

start on started httpd-user



# stop the service gracefully if the runlevel changes to 'reboot'

stop on runlevel [06]



# run the scripts as the 'http' user. Running as root (the default) is a bad idea.

setuid http



# exec the process. Use fully formed path names so that there is no reliance on $PATH

# the 'www' file is a node.js script which starts the foobar application.

exec /usr/bin/node /volume2/code/foobar/bin/www


Step 2. Start the service manually


The best part about keeping it simple is that you are more likely to get it running. If there is an error in your script, it won't start and it won't tell you why. It will just say the service could not be found.


To start the script, just type start foobar from the terminal. If it's happy, you'll see the process start and the PID displayed on the console. To stop it again, type 'stop foobar'.


Step 3. Check the script will auto-start


If you pass step 2 OK, then this is just a formality. The script will start when you restart your box. When ready type 'shutdown -r now' and allow your NAS to reboot. When it comes up again, you will be able to see that your service is running by hitting the URL, or by checking the logs which, by default, go to /var/log/upstart - all sysout from your process will go here.


ªÀº±Û Àϼö·Ï ½ÅÁßÇÏ°Ô.
DSM 6.0 ¿¡´Â Á¦¾îÆÇ -> ÀÛ¾÷ ½ºÄÉÁì·¯¿¡¼­ ºÎÆýà ½ÃÀÛ ¿É¼ÇÀ» ¼³Á¤ ÇÒ ¼ö ÀÖ´Â ¸Þ´º°¡ »ý±ä°É·Î ¾Ë°í ÀÖ¾î¿ä ^^;

°ð 6.0 ³ª¿À¸é ´õ¿í °£ÆíÇÏ°Ô ÇϽǼö ÀÖÀ¸½Çµí..
     
¿ì¿Í ±×·¸±º¿ä... ±â´ëµË´Ï´Ù ¤¾¤¾
Çسî·ÎÁöÁö¸¸ ¸¸Á·ÇÏ°í ÀÖ¾î¿ä...


NAS
Á¦¸ñPage 226/307
2015-12   1505232   ¹é¸Þ°¡
2014-05   4968903   Á¤ÀºÁØ1
2016-03   6149   ¿À¿ùÀÇÇູ
2016-03   6619   »ê°ñ³óºÎ
2016-03   6648   ¹ÚÁö¿ø
2016-03   9270   ½Öcpu
2016-03   22164   ³É³ÉÇϳÉ
2016-03   4956   öÀÌ´Ô
2016-03   9578   Å©¶óÀ̽º
2016-03   6477   ³É³ÉÇϳÉ
2016-03   15295   ³É³ÉÇϳÉ
2016-03   20481   ³É³ÉÇϳÉ
2016-03   6014   Mplit
2016-03   6600   ±è½ÂÇö1
2016-03   14647   ³É³ÉÇϳÉ
2016-03   3985   À縶
2016-03   10132   Àλý¿©Àü
2016-03   5947   TheSTREET
2016-03   4614   TheSTREET
2016-03   6109   audacity
2016-03   4645   audacity
2016-03   4942   w140