Changeset 377

Show
Ignore:
Timestamp:
11/13/06 11:59:27 (2 years ago)
Author:
luislavena
Message:

monative_service: added skeleton and service management to mongrel_service.
added process handling code.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/win32-native_service/projects/mongrel_service/Rakefile

    r374 r377  
    1515 
    1616desc "Does a full compile, test run" 
    17 task :default => [:test, :package] 
     17task :default => [:test, :compile, :package] 
    1818 
    1919version="0.3.0" 
     
    4444end 
    4545 
     46# too hackish, but get the job done, compile the ugly c code. 
     47task :compile_c do 
     48  sh %{cl /nologo /c native\\send_signal.cpp /Fonative\\send_signal.obj} 
     49  sh %{lib /nologo native\\send_signal.obj /out:lib\\libsend_signal.a} 
     50end 
     51task :compile => :compile_c 
     52 
    4653# ServiceFB namespace (lib) 
    4754namespace :lib do 
    4855  project_task 'servicefb' do 
    49     lib         'ServiceFB' 
    50     build_to    'lib' 
     56    lib       'ServiceFB' 
     57    build_to  'lib' 
    5158 
    52     source      'lib/ServiceFB/ServiceFB.bas' 
     59    define    'SERVICEFB_DEBUG_LOG' if ENV['DEBUG_LIB'] 
     60    source    'lib/ServiceFB/ServiceFB.bas' 
    5361  end 
    5462   
     
    5664    lib       'ServiceFB_Utils' 
    5765    build_to  'lib' 
    58      
     66 
     67    define    'SERVICEFB_DEBUG_LOG' if ENV['DEBUG_LIB'] 
    5968    source    'lib/ServiceFB/ServiceFB_Utils.bas' 
    6069  end 
    6170end 
    62 #add lib namespace to global tasks 
    63 include_projects_of :lib 
     71# add lib namespace to global tasks 
     72#include_projects_of :lib 
     73task :compile => "lib:build" 
    6474 
    6575# mongrel_service (native) 
     
    7080     
    7181    main        'native/mongrel_service.bas' 
     82    source      'native/process.bas' 
    7283     
    7384    # including the precompiled file show warnings when linking with 
    7485    # ld, due special m$ directives in the obj file 
    7586    # will solve that later, when migrate the asm part of code to gcc 
    76     source      'native/send_signal.o' 
     87    # source      'native/send_signal.o' 
    7788     
    7889    lib_path    'lib' 
    7990    library     'ServiceFB', 'ServiceFB_Utils' 
    80     library       'user32', 'advapi32', 'psapi' 
     91    library     'send_signal' 
     92    library     'user32', 'advapi32', 'psapi' 
    8193  end 
    8294end 
    83 include_projects_of :native 
     95#include_projects_of :native 
     96task :compile => "native:build" 
  • branches/win32-native_service/projects/mongrel_service/lib

    • Property svn:externals changed from
      ServiceFB http://opensvn.csie.org/servicefb/tags/release_0-2/lib/ServiceFB
      to
      ServiceFB http://opensvn.csie.org/servicefb/trunk/lib/ServiceFB
  • branches/win32-native_service/projects/mongrel_service/native/mongrel_service.bas

    r374 r377  
    2424'# in a pre-compiled form (also included the modified source code). 
    2525'# The C code is ugly as hell, but get the job done. 
     26'# 
     27'# Compile instructions: 
     28'# cl /c native\send_signal.cpp /Fonative\send_signal.obj 
     29'# lib native\send_signal.obj /out:lib\libsend_signal.a 
    2630'#  
    2731'################################################################## 
     
    3034 
    3135namespace mongrel_service 
     36    sub debug(byref message as string) 
     37        dim handle as integer 
     38         
     39        handle = freefile 
     40        open EXEPATH + "\service.log" for append as #handle 
     41         
     42        print #handle, message 
     43         
     44        close #handle 
     45    end sub 
     46     
    3247    constructor SingleMongrel() 
     48        with this.__service 
     49            .name = "single" 
     50            .description = "Mongrel Single Process service" 
     51             
     52            '# TODO: fix inheritance here 
     53            .onInit = @single_onInit 
     54            .onStart = @single_onStart 
     55            .onStop = @single_onStop 
     56        end with 
     57         
     58        '# TODO: fix inheritance here 
     59        single_mongrel = @this 
    3360    end constructor 
    3461     
    3562    destructor SingleMongrel() 
     63        '# TODO: fin inheritance here 
    3664    end destructor 
    3765     
    38     function SingleMongrel.onInit(byref self as ServiceProcess) as integer 
     66    function single_onInit(byref self as ServiceProcess) as integer 
    3967        dim result as integer 
     68        debug("single_onInit()") 
    4069         
     70        debug("single_onInit() done") 
    4171        return result 
    4272    end function 
    4373     
    44     sub SingleMongrel.onStart(byref self as ServiceProcess) 
     74    sub single_onStart(byref self as ServiceProcess) 
     75        debug("single_onStart()") 
     76        debug("single_onStart() done") 
    4577    end sub 
    4678     
    47     sub SingleMongrel.onStop(byref self as ServiceProcess) 
     79    sub single_onStop(byref self as ServiceProcess) 
     80        debug("single_onStop()") 
     81        debug("single_onStop() done") 
     82    end sub 
     83     
     84    sub application() 
     85        dim simple as SingleMongrel 
     86        dim host as ServiceHost 
     87        dim ctrl as ServiceController = ServiceController("Mongrel Win32 Service", "version 0.3.0", _ 
     88                                                            "(c) 2006 The Mongrel development team.") 
     89         
     90        '# add SingleMongrel (service) 
     91        host.Add(simple.__service) 
     92        select case ctrl.RunMode() 
     93            '# call from Service Control Manager (SCM) 
     94            case RunAsService: 
     95                host.Run() 
     96                 
     97            '# call from console, useful for debug purposes. 
     98            case RunAsConsole: 
     99                ctrl.Console() 
     100                 
     101            case else: 
     102                ctrl.Banner() 
     103                print "mongrel_service is not designed to run form commandline," 
     104                print "please use mongrel_rails service:: commands to create a win32 service." 
     105        end select 
    48106    end sub 
    49107end namespace 
     108 
     109'# MAIN: start native mongrel_service here 
     110mongrel_service.application() 
  • branches/win32-native_service/projects/mongrel_service/native/mongrel_service.bi

    r374 r377  
    2424'# in a pre-compiled form (also included the modified source code). 
    2525'# The C code is ugly as hell, but get the job done. 
     26'# 
     27'# Compile instructions: 
     28'# cl /c native\send_signal.cpp /Fonative\send_signal.obj 
     29'# lib native\send_signal.obj /out:lib\libsend_signal.a 
    2630'#  
    2731'################################################################## 
     
    3236namespace mongrel_service 
    3337    using fb.svc 
     38    using fb.svc.utils 
     39     
     40    declare function single_onInit(byref as ServiceProcess) as integer 
     41    declare sub single_onStart(byref as ServiceProcess) 
     42    declare sub single_onStop(byref as ServiceProcess) 
    3443     
    3544    '# SingleMongrel 
     
    3847        declare destructor() 
    3948         
    40         declare function onInit(byref self as ServiceProcess) as integer 
    41         declare sub onStart(byref self as ServiceProcess) 
    42         declare sub onStop(byref self as ServiceProcess) 
     49        '# TODO: replace for inheritance here 
     50        'declare function onInit() as integer 
     51        'declare sub onStart() 
     52        'declare sub onStop() 
    4353         
    44         _service        as ServiceProcess 
    45         _child_pid      as uinteger 
     54        __service       as ServiceProcess 
     55        __child_pid     as uinteger 
    4656    end type 
     57     
     58    '# TODO: replace with inheritance here 
     59    dim shared single_mongrel as SingleMongrel ptr 
    4760end namespace