³]¬°­º­¶¦¬ÂÃ¥»¯¸

Hippies

 §ä¦^±K½X
 ¥ß§Yµù¥U

±½¤@±½¡A³X°Ý·LªÀ°Ï

·j¯Á
¬d¬Ý: 3482|¦^´_: 5
¥´¦L ¤W¤@¥DÃD ¤U¤@¥DÃD

¦b Linux ¤W ¥Î C++ 来coding service application

[½Æ»sÃì±µ]
  • TAªº¨C¤é¤ß±¡
    ¶}¤ß
    2016-2-27 23:29
  • ñ¨ì¤Ñ¼Æ: 27 ¤Ñ

    [LV.4]°¸º¸¬Ý¬ÝIII

    438

    ¥DÃD

    611

    ©«¤l

    705

    ¿n¤À

    °ª¯Å·|­û

    Rank: 4

    ¿n¤À
    705
    ¸õÂà¨ì«ü©w¼Ó¼h
    ¼Ó¥D
    µoªí©ó 2015-12-9 16:33:26 | ¥u¬Ý¸Ó§@ªÌ ¦^©«¼úÀy |­Ë§ÇÂsÄý |¾\Ū¼Ò¦¡ 简体中文繁體中文
    ­n¦b Linux ¤W开发 Daemon application ¥i¥H参¦Ò¬Ý¬Ý¡AC++ 来开发¡C
    Linux Daemon Writing Howto

    Àò±o ¡A¬Ý¯fªá¤F {credit} {extcredits}. ¤@±i

    ¥d¤ù»¡©ú¡Jkevinhu ³Q¿ú³U¯{¤¤¶iÂå°

    ¥d¤ù®ÄªG¡J·l¥¢ 3 ª÷¿ú

  • TAªº¨C¤é¤ß±¡
    ¶}¤ß
    2016-2-27 23:29
  • ñ¨ì¤Ñ¼Æ: 27 ¤Ñ

    [LV.4]°¸º¸¬Ý¬ÝIII

    438

    ¥DÃD

    611

    ©«¤l

    705

    ¿n¤À

    °ª¯Å·|­û

    Rank: 4

    ¿n¤À
    705
    ¨Fµo
     ¼Ó¥D| µoªí©ó 2015-12-30 18:09:55 | ¥u¬Ý¸Ó§@ªÌ 简体中文繁體中文
  • TAªº¨C¤é¤ß±¡
    ¶}¤ß
    2016-2-27 23:29
  • ñ¨ì¤Ñ¼Æ: 27 ¤Ñ

    [LV.4]°¸º¸¬Ý¬ÝIII

    438

    ¥DÃD

    611

    ©«¤l

    705

    ¿n¤À

    °ª¯Å·|­û

    Rank: 4

    ¿n¤À
    705
    ªO¹¹
     ¼Ó¥D| µoªí©ó 2016-1-4 15:27:14 | ¥u¬Ý¸Ó§@ªÌ 简体中文繁體中文
    ¥»©«³Ì«á¥Ñ kevinhu ©ó 2016-1-6 11:53 ½s¿è

    Coding ¥u¬O§¹¦¨µ{§Ç¡A¦ý¬O­n±¾¤W¥hÁٻݭn¼g­ÓScript¤~¦æªº¡C
    °Ñ¦Òºô¯¸Ãì±µ
    How to Write Linux Init Scripts Based on LSB Init Standard
  • TAªº¨C¤é¤ß±¡
    ¶}¤ß
    2016-2-27 23:29
  • ñ¨ì¤Ñ¼Æ: 27 ¤Ñ

    [LV.4]°¸º¸¬Ý¬ÝIII

    438

    ¥DÃD

    611

    ©«¤l

    705

    ¿n¤À

    °ª¯Å·|­û

    Rank: 4

    ¿n¤À
    705
    ¦aªO
     ¼Ó¥D| µoªí©ó 2016-1-5 17:27:49 | ¥u¬Ý¸Ó§@ªÌ 简体中文繁體中文
    ¥»©«³Ì«á¥Ñ kevinhu ©ó 2016-1-19 15:10 ½s¿è

    ¦pªG­n¦b¶}¾÷®É¯à¦Û°Ê±Ò°Êªº¸ÜÁÙ¥²¶·­n¥ý¸ò¨t²Îµù¥U®@
    update-rc.d

    ©³¤U¬O¹ê§@ªº°Ñ¦Ò
    Auto-start Checklist for System VThis section is a quick reference to make sure your service is set to automatically start.
    Configuration Checklist
    • Make sure the service has a functional Bash init script located at /etc/init.d/service
    • Use the update-rc.d command to enable the service (or for a CentOS system, chkconfig):
    •   sudo update-rc.d service enable
    • This should create a symlink in /etc/rc2.d that looks like the following (do NOT create this manually):
      lrwxrwxrwx 1 root root  15 Jul 31 07:09 S02mysql -> ../init.d/serviceNote that you should also see links from directories /etc/rc3.d through /etc/rc5.d; learn more about these numbers when we discuss runlevels.
    • Add a respawn line for this service at the bottom of the /etc/inittab file. Here's a generic example:
    /etc/inittab
        id:2345:respawn:/bin/sh /path/to/application/startup
    • Stop, then start, the service:
    •   sudo service service stop
    •   sudo service service start
    • Reboot the server.
    •   sudo reboot
    Test
    To test that these are working, you can:
    • Reboot the server, then verify that the service is up
    • Search for the process number:
    •   ps -ef | grep service
    • Kill the process:
    •   sudo kill -9 process_number
    • Wait five minutes, then verify that the service is back up


  • TAªº¨C¤é¤ß±¡
    ¶}¤ß
    2016-2-27 23:29
  • ñ¨ì¤Ñ¼Æ: 27 ¤Ñ

    [LV.4]°¸º¸¬Ý¬ÝIII

    438

    ¥DÃD

    611

    ©«¤l

    705

    ¿n¤À

    °ª¯Å·|­û

    Rank: 4

    ¿n¤À
    705
    5#
     ¼Ó¥D| µoªí©ó 2016-3-29 11:10:21 | ¥u¬Ý¸Ó§@ªÌ 简体中文繁體中文
    ¦bLinux¤W¥Ø«e¦³3ºØ¥D­nInit System¡A¤À§O¬° SysVinit¡Bsystemd¤ÎUpstart¡A¨ÌLinux¦U­Ó¤À¤ä©Ò¿ï¥Î¬°¥D¡A¦³Ãö³o¨Çªº¨t²Îºt¶i±¡ªp¬Ý°Ñ¦Ò¤U¦CªºÃì±µ
    ²LªR Linux ªì©l¤Æ init ¨t²Î

    ¨Ï¥Îªº¤èªk¥i°Ñ¦Ò¤U¦CªºÂà¶K¤å¡G
    There are currently 3 main init systems used by linux. A few years ago, there was just one, SysVinit. But SysVinit was seriously lacking in capabilities such as service dependency graphing, so it's been deprecated in most distros by now. Currently most distros are switching to systemd. Though there is also upstart.

    But here's the answer to your question for each of the 3 init systems:


    SysVinit

    SysVinit currently used by Debian and RedHat. Though the next version of RedHat (7) will be using systemd.

    The univeral way of enabling SysVinit services on boot is to symlink them in /etc/rc3.d (or /etc/rc2.d). All services can be found in /etc/init.d. Note however that distros will often have their own tool for managing these files, and that tool should be used instead. (Fedora/RedHat has service and chkconfig, ubuntu has update-rc.d)
    List services:

    ls /etc/init.d/

    Start service:

    /etc/init.d/{SERVICENAME} start

    Stop service:

    /etc/init.d/{SERVICENAME} stop

    Enable service:

    cd /etc/rc3.d
    ln -s ../init.d/{SERVICENAME} S95{SERVICENAME}

    (the S95 is used to specify order. S01 will start before S02, etc)
    Disable service:

    rm /etc/rc3.d/*{SERVICENAME}


    Systemd

    The most notable distribution using systemd is Fedora. Though it is used by many others. Additionally, with Debian having chosen to go with systemd over upstart, it will become the defacto upstart system for most distributions (ubuntu has already announced they will be dropping upstart for systemd).
    List services:

    systemctl list-unit-files

    Start service:

    systemctl start {SERVICENAME}

    Stop service:

    systemctl stop {SERVICENAME}

    Enable service:

    systemctl enable {SERVICENAME}

    Disable service:

    systemctl disable {SERVICENAME}


    Upstart

    Upstart was developed by the Ubuntu folks. But after debian decided to go with systemd, Ubuntu announced they would drop upstart.

    Upstart was also briefly used by RedHat, as it is present in RHEL-6, but it is not commonly used.
    List services:

    initctl list

    Start service:

    initctl start {SERVICENAME}

    Stop service:

    initctl stop {SERVICENAME}

    Enable service:

    2 ways unfortunately:

        There will be a file /etc/default/{SERVICENAME} which contains a line ENABLED=.... Change this line to ENABLED=1.

        There will be a file /etc/init/{SERVICENAME}.override. Make sure it contains start (or is absent entirely), not manual.

    Disable service:

    echo manual > /etc/init/{SERVICENAME}.override
    [µo©«»Ú¹J]: kevinhu µo©«®É¦b¸ôÃä¾ß¨ì 3 ª÷¿ú¡A°½°½©ñ¶i¤F¤f³U. ©¯¹Bº] / °I¯«º]
  • TAªº¨C¤é¤ß±¡
    ¶}¤ß
    2016-2-27 23:29
  • ñ¨ì¤Ñ¼Æ: 27 ¤Ñ

    [LV.4]°¸º¸¬Ý¬ÝIII

    438

    ¥DÃD

    611

    ©«¤l

    705

    ¿n¤À

    °ª¯Å·|­û

    Rank: 4

    ¿n¤À
    705
    6#
     ¼Ó¥D| µoªí©ó 2016-4-12 14:23:57 | ¥u¬Ý¸Ó§@ªÌ 简体中文繁體中文
    ¥»©«³Ì«á¥Ñ kevinhu ©ó 2016-4-13 00:15 ½s¿è

    ¥Ø«e³\¦hLinuxªº·sª©¥»¤j¦hÂà´«¨Ï¥ÎSystemd¨ÓºÞ²zservice¡A¦]¦¹¦³»Ý­nªº¸ÜÁÙ¬O­n¤F¸Ñ¤@¤U¦bSystemdªº¬[ºc¤Îscriptªº½s¼g¤è¦¡¡A¬ÛÃö¸ê®Æ½Ð°Ñ¦Ò
    systemd »¡©ú

    ¤@½g°ê¥~¼gªº¤å³¹¹ïsystemdªº¨Ï¥Î»¡©ú¤Î¤ß±o
    Getting Started With systemd on Debian Jessie

    ³o¸Ì¦³¤@½g«ü¾É¦p¦ó¼¶¼gsystemdªºservice script¥H¤Î¦p¦ó¥ÑSysV init script Âà´«¦¨systemdªºunit file¡A¥X¦Û©óRedhat ªºAdministrator's Guid
    Creating and Modifying systemd Unit Files
    ±z»Ý­nµn¿ý«á¤~¥i¥H¦^©« µn¿ý | ¥ß§Yµù¥U

    ¥»ª©¿n¤À³W«h

    ¤p¶Â«Î|¤â¾÷ª©|Archiver|Hippies ¤â§@¥Ö­²¤u§@§{  

    GMT+8, 2024-12-22 22:51 , Processed in 0.106496 second(s), 17 queries , Apc On.

    Powered by Discuz! X3.2

    © 2001-2013 Comsenz Inc.

    §Ö³t¦^´_ ªð¦^³»³¡ ªð¦^¦Cªí