I copied the script (server.py) to /etc/init.d folder.
chmod 0744 /etc/init.d/server.py
chown root:sys /etc/init.d/server.py
cd /etc/init.d
ln server.py /etc/rc2.d/Sserver.py
ln server.py /etc/rc0.d/Kserver.py
ls /etc/init.d/*server.py /etc/rc2.d/*server.py /etc/rc0.d/*server.py
(able to see the links created in step 5 and 6)
then I power off the sunOS , and started. But unfortunately I can't see the server.py is running. I checked it using ps -ef.
I wanted to know ,is there anything I missed here or any other configuration steps were missing
After creating the correct symlinks, your script in
/etc/init.dwill be called withsys.argv[1] == 'start'upon startup andsys.argv[1] == 'stop'upon shutdown. Make sure it works with these values.To debug this further, write a debug script
/etc/init.d/mydebugcontaining this:, do the chmod, the chown, create the symlinks, reboot, and check the contents of the file
/tmp/mydebug.log.@AndrewHenle has commented that on SunOS the run-control scripts are sourced by
/bin/sh. To accommodate this, start your Python script like this (and then follow with Python source code):Replace
pythonabove with/usr/local/bin/pythonor wherever your Python interpreter is.This will make it work in both cases: if it's exec()ed and if it's sourced by
/bin/sh.Based on your comment, SunOS is running the mydebug script at startup. So there is a problem with server.py only (not with mydebug).
You mention starting server.py with
#!/usr/bin/python. This doesn't work if run-control scripts are sourced by/bin/sh. Instead of this line, please use the 2 lines I've recommended above instead. Don't forget to changepythonto/usr/local/bin/pythonif your Python interpreter is there.As a preparation, run this as root:
To diagnose this further, run this from the command-line as root:
The command above is equivalent to what's happening at SunOS system startup. But in here you will get a direct error message, and you can retry it quickly, without having to restart your system.
Success looks like this: the server.py program starts the server in the background and exits successfully (you see
Exit code: 0). If you see anything else (e.g. a different exit code, an error message, server.py doesn't exit quickly), then that's an error which you have to fix in your own code (server.py). You may want to ask a separate question about that on StackOverflow.