| Line 1: |
Line 1: |
| − | == List all running services == | + | ==List all running services== |
| | sytemctl | | sytemctl |
| − | == Start/stop or enable/disable services == | + | watch "ps -ef|grep service" |
| | + | |
| | + | ==Start/stop or enable/disable services== |
| | systemctl start foo.service | | systemctl start foo.service |
| | systemctl stop foo.service | | systemctl stop foo.service |
| Line 8: |
Line 10: |
| | systemctl enable foo.service | | systemctl enable foo.service |
| | systemctl disable foo.service | | systemctl disable foo.service |
| − | == Check if service is enabled == | + | ==Check if service is enabled== |
| | systemctl is-enabled foo.service; echo $? | | systemctl is-enabled foo.service; echo $? |
| | | | |
| Line 14: |
Line 16: |
| | [https://www.dynacont.net/documentation/linux/Useful_SystemD_commands/ Useful SystemD Commands] | | [https://www.dynacont.net/documentation/linux/Useful_SystemD_commands/ Useful SystemD Commands] |
| | | | |
| − | == Log to syslog == | + | ==Log to syslog== |
| | Use the following properties in your systemd service unit file: | | Use the following properties in your systemd service unit file: |
| | StandardOutput=syslog | | StandardOutput=syslog |
| Line 24: |
Line 26: |
| | if $programname == '<your program identifier>' then ~ | | if $programname == '<your program identifier>' then ~ |
| | | | |
| − | == /etc/systemd/system/example.service == | + | ==/etc/systemd/system/example.service== |
| − | <nowiki>[Unit] | + | [Unit] |
| − | Description=Tenkaichi Vegeta-server (Tentacle) | + | Description=Tenkaichi Vegeta-server (Tentacle) |
| − | After=network.target | + | After=network.target |
| | + | |
| | + | [Service] |
| | + | User=tenkaichi |
| | + | Group=tenkaichi |
| | + | WorkingDirectory=/home/tenkaichi/vegetas-server |
| | + | EnvironmentFile=/tenkaichi/vegeta-server/cfg/environment.cfg |
| | + | StandardOutput=syslog |
| | + | StandardError=syslog |
| | + | SyslogIdentifier=Vegeta-Tentacle |
| | + | Restart=always |
| | + | RestartSec=3 |
| | + | |
| | + | ExecStart=/usr/local/bin/tentacle_server -o -a ${SERVER_IP} -p ${PORT} -s ${INPUT_DIR} -v -m ${MAX_SIZE} -e ${SSL_CERT} -k ${SSL_CERTKEY} |
| | + | |
| | + | [Install] |
| | + | WantedBy=multi-user.target |
| | + | |
| | | | |
| − | [Service]
| + | ==Automatic restart== |
| − | User=tenkaichi
| + | Add the following lines to your service file at Service block |
| − | Group=tenkaichi
| + | [Service] |
| − | WorkingDirectory=/home/tenkaichi/vegetas-server
| + | ... |
| − | EnvironmentFile=/tenkaichi/vegeta-server/cfg/environment.cfg
| + | Restart=always |
| − | StandardOutput=syslog
| + | RestartSec=3 |
| − | StandardError=syslog
| + | ... |
| − | SyslogIdentifier=Vegeta-Tentacle
| |
| − | Restart=always | |
| − | RestartSec=3 | |
| | | | |
| − | ExecStart=/usr/local/bin/tentacle_server -o -a ${SERVER_IP} -p ${PORT} -s ${INPUT_DIR} -v -m ${MAX_SIZE} \
| + | ==Wait Online== |
| − | -e ${SSL_CERT} -k ${SSL_CERTKEY}
| + | <nowiki>[Unit] |
| | + | Wants=network-online.target |
| | + | After=network.target network-online.target</nowiki> |
| | + | ===With NetworkManager=== |
| | + | systemctl enable NetworkManager-wait-online |
| | | | |
| − | [Install]
| + | ==ExecStart examples== |
| − | WantedBy=multi-user.target
| |
| − | </nowiki>
| |
| | | | |
| − | == Automatic restart == | + | ======Gunicorn====== |
| − | Add the following lines to your service file at Service block
| + | ExecStart=/virtualenv/path/bin/gunicorn -w3 --timeout 300 --access-logfile /var/log/gunicorn/app-access.log --error-logfile /var/log/gunicorn/app-error.log --bind unix:/sockets/app-socket.sock App.wsgi |
| − | Restart=always
| |
| − | RestartSec=3 | |
| | | | |
| − | == Gunicorn == | + | ====Flask (superset)==== |
| − | ExecStart=/virtualenv/path/bin/gunicorn -w3 --timeout 300 --access-logfile /var/log/gunicorn/app-access.log --error-logfile /var/log/gunicorn/app-error.log --bind unix:/sockets/app-socket.sock App.wsgi
| + | <syntaxhighlight lang="text"> |
| | + | ExecStart=/home/superset/.virtualenvs/superset/bin/gunicorn -w 3 -k gevent --timeout 120 -b unix:/home/superset/.superset/superset.sock --limit-request-line 0 --limit-request-field_size 0 --statsd-host localhost:8125 superset:app |
| | + | </syntaxhighlight> |