Login

OpenSolaris SMF Django Daemon Script

Author:
davidblewett
Posted:
July 10, 2009
Language:
Python
Version:
1.0
Score:
0 (after 0 ratings)

This is the manifest for being able to start django daemons via django-admin. A sample instance ('signet') is included.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<service_bundle type="manifest" name="django">
  <service name="network/django" type="service" version="4">
    <create_default_instance enabled="false"/>

    <!--
    If there's no network, then there's no point in running
    -->
    <dependency name='network'
        grouping='require_all'
        restart_on='error'
        type='service'>
        <service_fmri value='svc:/milestone/network:default'/>
    </dependency>

    <dependency
      name="fs-local"
      grouping="require_all"
      restart_on="none"
      type="service">
      <service_fmri value="svc:/system/filesystem/local"/>
    </dependency>

    <dependency
        name="django_var"
        grouping="require_all"
        restart_on="restart"
        type="path">
        <service_fmri value="file://localhost/var/run/django"/>
    </dependency>

    <dependency
        name="django_admin"
        grouping="require_all"
        restart_on="restart"
        type="path">
        <service_fmri value="file://localhost/usr/bin/django-admin.py"/>
    </dependency>


    <method_context>
         <method_credential user='webservd' group='webservd' />
    </method_context>

    <exec_method
      type="method"
      name="start"
      exec="django-admin.py runfcgi --settings=%i.settings protocol=%{config/protocol} method=%{config/method} maxchildren=%{config/maxchildren} minspare=%{config/minspare} max$
      timeout_seconds="60"/>
    <exec_method
      type="method"
      name="stop"
      exec=":kill"
      timeout_seconds="60"/>
    <exec_method
      type="method"
      name="refresh"
      exec=":kill -HUP"
      timeout_seconds="60"/>

    <property_group name='general' type='framework'>
        <propval name='action_authorization' type='astring'
                value='solaris.smf.manage.django' />

            <!--
                If the authorization is intended to cover permanent
                enable/disable as well as temporary, add the following
            -->
        <propval name='value_authorization' type='astring'
                value='solaris.smf.manage.django' />
    </property_group>

    <property_group name="startd" type="framework">
                <!-- sub-process core dumps shouldn't restart
                        session -->
                <propval name='ignore_error' type='astring' value='core,signal' />
    </property_group>

    <property_group name='config' type='application'>
            <!-- other application properties
            -->
            <propval name='host'        type='astring' value='' />
            <propval name='port'        type='integer' value='5' />
            <property name="method"     type="astring">
                    <astring_list>
                        <value_node value="threaded" />
                        <value_node value="prefork" />
                    </astring_list>
            </property>
            <propval name='maxspare'    type='integer' value='2' />
            <propval name='minspare'    type='integer' value='5' />
            <propval name='daemonize'   type='boolean' value='true' />
            <property name='protocol'   type="astring">
                    <astring_list>
                        <value_node value="fcgi" />
                        <value_node value="scgi" />
                        <value_node value="ajp" />
                    </astring_list>
            </property>
            <propval name='maxchildren' type='integer' value='5' />

            <propval name='value_authorization' type='astring' value='solaris.smf.value.django' />
    </property_group>

    <instance name='signet' enabled='false'>
         <!-- instance-specific properties, methods, etc. go here. -->
        <property_group name='config'   type='application'>
            <propval name='protocol'    type='astring' value='fcgi' />
            <propval name='method'      type='astring' value='prefork' />
        </property_group>
    </instance>

    <stability value="Unstable"/>
    <template>
      <common_name>
        <loctext xml:lang="C">Django CGI Daemon(s)</loctext>
      </common_name>

      <documentation>
        <doc_link name="django.org" uri="http://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/"/>
      </documentation>
    </template>
  </service>
</service_bundle>

More like this

  1. Template tag - list punctuation for a list of items by shapiromatron 2 months, 2 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 2 months, 3 weeks ago
  3. Serializer factory with Django Rest Framework by julio 9 months, 2 weeks ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 10 months, 1 week ago
  5. Help text hyperlinks by sa2812 11 months ago

Comments

Please login first before commenting.