daemonization
Closed this issue · 2 comments
"To actually run the server, run the otsd program. Proper daemonization isn't implemented yet, so otsd runs in the foreground. "
Is it worth noting using screen, solves issues with terminal disconnect and background tho not a daemon?
screen -S opentimestampserver ./otsd
- Detach: Ctrl+a d
- Find: screen ls
- Reattach: screen -r
TLDR:
With systemd, a service can now be written as if it was running in the foreground, just like any other program. So probably you can use the service configuration I wrote here.
Long answer:
The old style python daemons following PEP 3143 is provided by the python-daemon standard library.
(BTW: When I tried to use it for a small script I ran into some problems and I found mixed opinions around.)
Systemd allow a new-style daemons in Python: simply don't daemonize your code at all!
If you don't have Systemd you can try supervisord.
A nice post with many citation is this too.
Thank you, worked perfectly!
[ec2-user@ip-172-31-61-7 systemd]$ sudo service otsd.service status
Redirecting to /bin/systemctl status otsd.service
● otsd.service - OpenTimestamps server
Loaded: loaded (/etc/systemd/system/otsd.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2021-02-02 17:41:34 UTC; 11s ago
Main PID: 28057 (python3)
CGroup: /system.slice/otsd.service
└─28057 python3 /home/ec2-user/opentimestamps-server/otsd
Feb 02 17:41:34 ip-172-31-61-7.ec2.internal systemd[1]: Started OpenTimestamps server.
Feb 02 17:41:34 ip-172-31-61-7.ec2.internal systemd[1]: Starting OpenTimestamps server...
Feb 02 17:41:35 ip-172-31-61-7.ec2.internal otsd[28057]: Opening journal for appending...
Feb 02 17:41:35 ip-172-31-61-7.ec2.internal otsd[28057]: Journal has 1 entries
Feb 02 17:41:35 ip-172-31-61-7.ec2.internal otsd[28057]: Starting aggregator loop
Feb 02 17:41:35 ip-172-31-61-7.ec2.internal otsd[28057]: Starting stamper loop