복붙노트

[PYTHON] CherryPy (데몬) 배포

PYTHON

CherryPy (데몬) 배포

나는 CherryPy 기본 튜토리얼 (http://www.cherrypy.org/wiki/CherryPyTutorial)을 따라왔다. 논의되지 않은 한 가지는 배포입니다.

CherryPy 앱을 데몬으로 시작하고 "잊어 버리면"어떻게 할 수 있습니까? 서버를 재부팅하면 어떻게됩니까?

표준 레시피가 있습니까? 어쩌면 서비스 스크립트 (/etc/init.d/cherrypy ...)를 만들 수 있습니다.

감사!

해결법

  1. ==============================

    1.기본적으로 포함 된 CherryPy 용 Daemonizer 플러그인이 있습니다.이 플러그인은 시작할 때 유용하지만 간단한 경우에 가장 쉬운 방법은 cherryd 스크립트를 사용하는 것입니다.

    기본적으로 포함 된 CherryPy 용 Daemonizer 플러그인이 있습니다.이 플러그인은 시작할 때 유용하지만 간단한 경우에 가장 쉬운 방법은 cherryd 스크립트를 사용하는 것입니다.

    > cherryd -h
    Usage: cherryd [options]
    
    Options:
      -h, --help            show this help message and exit
      -c CONFIG, --config=CONFIG
                            specify config file(s)
      -d                    run the server as a daemon
      -e ENVIRONMENT, --environment=ENVIRONMENT
                            apply the given config environment
      -f                    start a fastcgi server instead of the default HTTP
                            server
      -s                    start a scgi server instead of the default HTTP server
      -i IMPORTS, --import=IMPORTS
                            specify modules to import
      -p PIDFILE, --pidfile=PIDFILE
                            store the process id in the given file
    

    늘어나는 한 init.d 스크립트는 Google 검색이 가능한 예제가 있다고 생각합니다.

    그리고 cherryd는 당신에게서 발견됩니다 :

    또는 : https://bitbucket.org/cherrypy/cherrypy/src/default/cherrypy/cherryd

  2. ==============================

    2.Daemonizer는 사용하기가 매우 쉽습니다.

    Daemonizer는 사용하기가 매우 쉽습니다.

    # this works for cherrypy 3.1.2 on Ubuntu 10.04
    from cherrypy.process.plugins import Daemonizer
    # before mounting anything
    Daemonizer(cherrypy.engine).subscribe()
    
    cherrypy.tree.mount(MyDaemonApp, "/")
    cherrypy.engine.start()
    cherrypy.engine.block()
    

    여기 SysV 스타일을위한 괜찮은 HOWTO가있다.

    요약:

  3. ==============================

    3.웹 개발자를 위해 Debian *에서 실제 CherryPy 응용 프로그램을 배포하기위한 격차를 메우기위한 자습서 / 프로젝트 뼈대 인 cherrypy-webapp-skeleton을 작성했습니다. 데몬 권한 삭제를 위해 확장 된 cherryd가 있습니다. init.d, nginx, monit, logrotate에 대한 중요한 스크립트 및 구성 파일도 많이 있습니다. 튜토리얼 파트에서는, 모든 것을 조합 해 결국 잊어 버리는 방법을 설명합니다. 스켈레톤 부분은 CherryPy webapp 프로젝트 자산을 배치 할 수있는 방법을 제안합니다.

    웹 개발자를 위해 Debian *에서 실제 CherryPy 응용 프로그램을 배포하기위한 격차를 메우기위한 자습서 / 프로젝트 뼈대 인 cherrypy-webapp-skeleton을 작성했습니다. 데몬 권한 삭제를 위해 확장 된 cherryd가 있습니다. init.d, nginx, monit, logrotate에 대한 중요한 스크립트 및 구성 파일도 많이 있습니다. 튜토리얼 파트에서는, 모든 것을 조합 해 결국 잊어 버리는 방법을 설명합니다. 스켈레톤 부분은 CherryPy webapp 프로젝트 자산을 배치 할 수있는 방법을 제안합니다.

    * Squeeze를 위해 쓴 것이지만 실제로는 Wheezy와 동일해야합니다.

  4. ==============================

    4.Daemonizer 옵션에 대한 정보

    Daemonizer 옵션에 대한 정보

    Daemonizer를 사용할 때 문서는 옵션을 명시하지 않습니다. stdout 또는 stderr를 리디렉션하는 방법. Daemonizer 클래스의 소스에서 옵션을 찾을 수 있습니다. 참고로이 프로젝트를 내 프로젝트에서 가져온다 :

    # run server as a daemon
    d = Daemonizer(cherrypy.engine,
                   stdout='/home/pi/Gate/log/gate_access.log',
                   stderr='/home/pi/Gate/log/gate_error.log')
    d.subscribe()
    
  5. from https://stackoverflow.com/questions/1463510/deploying-cherrypy-daemon by cc-by-sa and MIT license