Starting Services on Linux
✕
  • Solutions
    • Legacy Application Modernization
    • Distributed Computing
    • Modern UI/UX
    • Data Visibility
    • Enterprise Application Integration
    • Development Environment Optimization
    • Cloud Migration
    • Security
    • High Availability and Resilience
  • Products
    • Language
    • Development Environment
    • .NET Integration
    • Streaming Integration Platform
    • Web Services Framework
    • Roadmap
  • Services and Support
    • Professional Services Group
    • Developer Support
    • Application Support
  • Learning
    • Events
    • Online Courses
    • White Papers
    • Case Studies
    • Learning Resources
    • Blog
    • Synergy-e-News
  • Company
    • Leadership
    • Careers
    • Contact
    • News
  • +1-916-635-7300
  • Get Support
  • Documentation
  • Resource Center
✕
            No results See all results
            Starting Services on Linux
            • Solutions
              • Legacy Application Modernization
              • Distributed Computing
              • Modern UI/UX
              • Data Visibility
              • Enterprise Application Integration
              • Development Environment Optimization
              • Cloud Migration
              • Security
              • High Availability and Resilience
            • Products
              • Language
              • Development Environment
              • .NET Integration
              • Streaming Integration Platform
              • Web Services Framework
              • Roadmap
            • Services and Support
              • Professional Services Group
              • Developer Support
              • Application Support
            • Learning
              • Events
              • Online Courses
              • White Papers
              • Case Studies
              • Learning Resources
              • Blog
              • Synergy-e-News
            • Company
              • Leadership
              • Careers
              • Contact
              • News
            • +1-916-635-7300
            • Get Support
            • Documentation
            • Resource Center
            ✕
                      No results See all results
                      Starting Services on Linux
                      • Solutions
                        • Legacy Application Modernization
                        • Distributed Computing
                        • Modern UI/UX
                        • Data Visibility
                        • Enterprise Application Integration
                        • Development Environment Optimization
                        • Cloud Migration
                        • Security
                        • High Availability and Resilience
                      • Products
                        • Language
                        • Development Environment
                        • .NET Integration
                        • Streaming Integration Platform
                        • Web Services Framework
                        • Roadmap
                      • Services and Support
                        • Professional Services Group
                        • Developer Support
                        • Application Support
                      • Learning
                        • Events
                        • Online Courses
                        • White Papers
                        • Case Studies
                        • Learning Resources
                        • Blog
                        • Synergy-e-News
                      • Company
                        • Leadership
                        • Careers
                        • Contact
                        • News
                      • Home
                      • Blog
                      • Software
                      • Starting Services on Linux

                      Starting Services on Linux

                      Published by Steve Ives on July 24, 2010
                      Categories
                      • Software
                      Tags
                      • License Manager
                      • Linux
                      • OpenNET Server
                      • xfServer
                      • xfServerPlus

                      For a while now I’ve been wondering about what the correct way is to start boot time services such as the Synergy License Manager, xfServer and xfServerPlus on Linux systems. A few years ago I managed to “cobble something together” that seemed to work OK, but I had a suspicion that I only had part of the solution. For example, while I could make my services start at boot time, I’m not sure that they were getting stopped in a “graceful” way during system shutdown. I also wondered why my “services” didn’t show up in the graphical service management tools.

                      My cobbled together solution involved placing some appropriately coded scripts into the /etc/rc.d/init.d folder, then creating symbolic links to those files in the appropriate folders for the run levels that I wanted my services started in, for example /etc/rc.d/rc5.d.

                      This week, while working on a project on a Linux system, I decided to do some additional research and see if I couldn’t fill in the blanks and get things working properly.

                      My previous solution, as I mentioned, involved placing an appropriately coded script in the /etc/rc.d/init.d folder. Turns out that part of my previous solution was correct. For the purposes of demonstration, I’ll use the Synergy License Manager as an example; my script to start, stop, restart and determine the status of License Manager looked like this:

                      #

                      # synlm – Start and stop Synergy License Manager

                      #

                      . /home/synergy/931b/setsde

                      case "$1" in

                         

                      start)

                              echo -n "Starting Synergy License Manager"

                             

                      synd

                             

                      ;;

                         

                      stop)

                             

                      echo -n "Stopping Synergy License Manager"

                             

                      synd –q

                             

                      ;;

                         

                      restart)

                             

                      $0 stop

                             

                      $0 start

                             

                      ;;

                         

                      status)

                             

                      if ps ax | grep -v grep | grep -v rsynd | grep synd > /dev/null

                             

                      then

                                 

                      echo "License Manager is running (pid is `pidof synd`)"

                             

                      else

                                 

                      echo "License Manager is NOT running"

                              fi

                             

                      ;;

                         

                      *)

                             

                      echo $"Usage: synlm {start|stop|restart|status}"

                             

                      exit 1

                      esac

                      exit 0

                      If you have ever done any work with UNIX shell scripts then this code should be pretty self explanatory. The script accepts a single parameter of start, stop, restart or status, and takes appropriate action. The script conforms to the requirements of the old UNIX System V init subsystem, and if placed in an appropriate location will be called by init as the system runlevel changes. As mentioned earlier, I had found that if I wanted the “service” to start, for example when the system went to runlevel5, I could create a symbolic link to the script in the /etc/rc.d/rc5.d folder, like this:

                      ln –s /etc/rc.d/init.d/synlm /etc/rc.d/rc5.d/S98synlm

                      Init seems to process files in a run level folder alphabetically, and the existing scripts in the folder all seemed to start with S followed by a two digit number. So I chose the S98 prefix to ensure that License Manager would be started late in the system boot sequence.

                      This approach seemed to work pretty well, but it was kind of a pain having to create all those symbolic links … after all, on most UNIX and LINUX systems, run levels 2, 3, 4 and 5 are all multi-user states, and probably required License Manager to be started.

                      Then, almost by accident, I stumbled across a command called chkconfig. Apparently this command is used to register services (or more accurately init scripts) to be executed at various run levels. PERFECT … I thought! I tried it out:

                      # chkconfig –-level 2345 synlm on

                      service synlm does not support chkconfig

                      Oh! … back to Google… Turns out I was something really critical in my script, and believe it or not, what I was missing was a bunch of comments! After doing a little more research I added these lines towards the top of the script:

                      # chkconfig: 2345 98 20

                      # description: Synergy/DE License Manager

                      # processname: synd

                      Low and behold, this was the missing piece of the puzzle! Comments … you gotta love UNIX! So now all I have to do to start License Manager at boot time, and stop it at system shutdown is use the chkconfig command to “register” the service.

                      And there’s more … With License Manager registered as a proper service, you can also use the service command to manipulate it. For example, to manually stop the service you can use the command:

                      # service synlm stop

                      And of course you can also use similar commands to start, restart, or find the status of the service. Basically, whatever operations are supported by the init script that you provide.

                      Oh, by the way, because License Manager is now running as a proper service it also shows up in the graphical management tools, and can be manipulated by those tools … very cool!

                      Of course License Manager is just one of several Synergy services that you could use this same technique with. There’s also xfServer, xfServerPlus and the SQL OpenNet server.

                      Share
                      96

                      Leave a ReplyCancel reply

                      This site uses Akismet to reduce spam. Learn how your comment data is processed.

                      • With 40 Years at Synergex, Bill Mooney Is All In
                      • New 12.4 Features Release, 12.4.1.1003
                      • New SDI Release, 2025.06.1647
                      • Simple Strategies to Modernize Your Legacy Code
                      • Unlocking the Power of Modern Web Services: New White Paper Released
                      • Announcements
                      • Beta Testing
                      • Case Studies
                      • Code Exchange
                      • CodeGen
                      • CTO's Thoughts
                      • Development Tools
                      • DevPartner Conference
                      • Education
                      • Events
                      • Harmony Core
                      • Hiring
                      • Industry News
                      • Just for Fun
                      • Licensing
                      • News
                      • Open Source
                      • OpenVMS
                      • President's Thoughts
                      • Professional Services Group
                      • Release Notifications
                      • Security
                      • Software
                      • Software Development
                      • Success Stories
                      • Tech Article
                      • UI
                      • Uncategorized
                      • White Papers

                      STAY CONNECTED with Synergex

                      • Blog
                      • Facebook
                      • LinkedIn
                      • YouTube
                      SOLUTIONS
                      • Legacy Applications Modernization
                      • Modern UI/UX
                      • Data Visibility
                      • Enterprise Application Integration
                      • Development Environment Optimization
                      • Cloud Migration
                      • Security
                      • High Availability
                      PRODUCTS
                      • Language
                      • Development Environment
                      • Connectivity and Open-Source Tools
                      • Release Strategy
                      • Roadmap
                      SUPPORT
                      • Professional Services Group
                      • Developer Support
                      • Application Support
                      LEARNING
                      • Events
                      • Online Courses
                      • Learning Resources
                      • Blog
                      • Synergy-e-News
                      COMPANY
                      • Customers
                      • Leadership
                      • Careers
                      • Contact
                      Starting Services on Linux

                      Privacy  |  Security  |  Terms  |  © 2024 Synergex

                      Linux ls Color Coding
                      July 20, 2010
                      Building Distributed Apps with Synergy/DE and WCF
                      June 22, 2011
                      Linux ls Color Coding
                      July 20, 2010
                      Building Distributed Apps with Synergy/DE and WCF
                      June 22, 2011