Php server startup at boot

  • Hello everyone!


    Thanks in advance for the help, and sorry for my approximate english.


    In my OMV 2 machine, I have installed COPS server (http://blog.slucas.fr/en/oss/calibre-opds-php-server).
    This php server starts with a command like this:
    php -S 192.168.1.96:8080


    Everything works wonderfully, but I have to run manually the php server, every time, giving the command in a terminal window via ssh.


    How can I start the php server at boot of my OMV machine, and run it in background, continuously & all the time?


    I'm inexperienced in scripting and similar things, so I would like to ask for help...


    Thank you very much!
    Federico

  • Add that command to the file /etc/rc.local above the line that says exit 0

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

    • Offizieller Beitrag

    It would be better to write an init script. An init script can restart your program if it dies, the others only happen when you reboot.


    A quick google (Calibre OPDS server init script) found this. https://gist.github.com/razrichter/4157867 Have not looked too close at it so use at your own risk.

  • From your link:


    "rc.local is being deprecated"


    Best not to rely on it then. In this case it's a bit of a kludge

    But your position is not applicable until OMV is on Stretch. And right now, it isn't.

    --
    Google is your friend and Bob's your uncle!


    OMV AMD64 7.x on headless Chenbro NR12000 1U 1x 8m Quad Core E3-1220 3.1GHz 32GB ECC RAM.

  • That's fair, but it's not the "proper" use per se of rc local.


    Because it's basically an application, it would be better to write a systemd init script for such uses.


    If he only starts the app on each multiuser runlevel (ie. rc local), if it failed for some reason he'd have to ssh into the box to restart it. For this reason alone it makes much more sense to write an init script.


    It's not terribly difficult to write a simple init script-- the one linked in this thread however will probably not work without modification as it's looks like it is for calibre itself and not the homebrew app the original poster is using- though I could be mistaken.

    • Offizieller Beitrag

    Actually, on OMV 3.x, you should write a systemd unit file. Would be very simple:

    Create that file at /lib/systemd/system/php-app.service and enable it with systemctl enable php-app.service

  • Thank you all!


    @ryecoaaron: I've created/lib/systemd/system/COPS.service


    However, my machine runs OMV 2: perhaps that's why
    systemctl enable COPS.service
    returns
    -bash: systemctl: command not found


    I can put your script in /etc/init.d/ folder, and then automate it with update-rc.d?


    I've read something similar in Debian documentation...


    In the meantime, I try the solution proposed by @macom

    • Offizieller Beitrag

    I can put your script in /etc/init.d/ folder, and then automate it with update-rc.d?

    Nope. That is a unit file that only works with systemd. An init script for sysvinit that OMV 2.x uses is a bit more complicated.

    omv 7.0.5-1 sandworm | 64 bit | 6.8 proxmox kernel

    plugins :: omvextrasorg 7.0 | kvm 7.0.13 | compose 7.1.4 | k8s 7.1.0-3 | cputemp 7.0.1 | mergerfs 7.0.4


    omv-extras.org plugins source code and issue tracker - github - changelogs


    Please try ctrl-shift-R and read this before posting a question.

    Please put your OMV system details in your signature.
    Please don't PM for support... Too many PMs!

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!