Usage Example

Basic Usage Example

#!/usr/bin/env python
# encoding: utf-8

# Copyright (C) 2015 Chintalagiri Shashank
# Released under the MIT license.

"""

Simple Deployment Example
-------------------------

"""

from vcs_monitor import worker
from twisted.internet import reactor

import logging
logging.basicConfig(level=logging.INFO)

if __name__ == '__main__':
    worker.start()
    reactor.run()

Self-contained Usage : Deploy using twistd and systemd

Twisted .tac file:



"""

TAC Deployment Example
----------------------

A more usable example.

The important part of this, the part that makes it a .tac file, is
the final root-level section, which sets up the object called
'application' which twistd will look for.

You can run this .tac file directly with ::

    twistd -ny vcs_monitor.tac

"""

# import sys
# from twisted.python import log
# log.startLogging(sys.stdout)

from twisted.application import service
from twisted.python.log import ILogObserver, FileLogObserver
from twisted.python.logfile import LogFile


# this is the core part of any tac file, the creation of the root-level
# application object
application = service.Application("Tendril VCS Monitor")
logfile = LogFile("vcs_monitor.log", "/var/log/tendril")
application.setComponent(ILogObserver, FileLogObserver(logfile).emit)


# attach the service to its parent application
from vcs_monitor import worker
worker.start()

Systemd .service file:


[Unit]
Description=Tendril VCS Monitoring Server

[Service]
ExecStart=/usr/bin/twistd --nodaemon --pidfile= vcs_monitor.tac

WorkingDirectory=/home/tendril/tools/vcs_monitor/deploy

User=tendril
Group=tendril

Restart=always

[Install]
WantedBy=multi-user.target

s