Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    How to add custom service to v2.1?

    Scheduled Pinned Locked Moved Development
    3 Posts 2 Posters 1.8k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R Offline
      robi
      last edited by

      I've made a custom perl script doing things in the background. I start it with "daemon -p /var/run/myapp.pid /root/my_app.pl"

      I even made a service script (myapp.sh):```
      #!/bin/sh

      Service handler for pitty plyayer

      rc_start() {
              daemon -p /var/run/myapp.pid /root/my_app.pl
      }

      rc_stop() {
              [ -f "/var/run/myapp.pid" ] && kill -9 cat /var/run/myapp.pid && rm -f /var/run/myapp.pid
      }

      case $1 in
              start)
                      rc_start
                      ;;
              stop)
                      rc_stop
                      ;;
              restart)
                      rc_stop
                      rc_start
                      ;;
      esac

      
      Question is: how to add it to the system so that it can be viewed through the web interface?
      
      I tried to add to /etc/inc/service-utils.inc this, but it doesn't appear in the list:```
              if(isset($config['myapp']['enable'])) {
                      $pconfig = array();
                      $pconfig['name'] = "myapp";
                      $pconfig['description'] = gettext("My App");
                      $services[] = $pconfig;
              }
      

      1 Reply Last reply Reply Quote 0
      • jimpJ Offline
        jimp Rebel Alliance Developer Netgate
        last edited by

        The simplest way is to just add it into your config.xml as a <service>…</service> tag as used by packages. Plenty of examples in the package repo xml files.

        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply Reply Quote 0
        • R Offline
          robi
          last edited by

          OK I'll try that, thanks.

          I already thougt of making a package for it, but the product is not ready yet.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.