Showing posts with label init. Show all posts
Showing posts with label init. Show all posts

Tuesday, May 12, 2015

systemd quickstart


Source:
https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet
https://wiki.ubuntu.com/SystemdForUpstartUsers
http://wiki.nginx.org/FedoraSystemdServiceFile

Start/stop/reload a service:
service foo start   # or
systemctl start foo

service foo stop   # or 
systemctl stop foo

service foo restart   # or 
systemctl restart foo

Reload a service using reload signal:
service foo reload

See if service is running:
service foo status   # or 
systemctl status foo

See tree listing of all services:
systemctl status

See job log: 
sudo journalctl -u foo -f

Enable a service (to start on boot):
systemctl enable foo

Disable a service:
systemctl disable foo

Service Definition Directory:
/lib/systemd/system/

Example Nginx Service: /lib/systemd/system/nginx.service 
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target


Links:
https://scottlinux.com/2014/12/08/how-to-create-a-systemd-service-in-linux-centos-7/

Friday, May 17, 2013

Supervisord Common Commands


Invoke the supervisor shell:
sudo supervisorctl

# all of the following commands can be run within the supervisor shell or from the UNIX CLI

View processes managed by supervisord:
sudo supervisorctl status

Start/Stop/Restart processes from the UNIX command line:
sudo supervisorctl start processname
sudo supervisorctl stop processname
sudo supervisorctl restart processname

View standard error:
supervisorctl tail -f  processname stderr

Load changes to configuration without restarting unaffected processes:
supervisorctl reread  # reads the configuration changes
supervisorctl update  # restarts changed process groups

Reload supervisor processes and configurations, but doesn't restart supervisor itself:
supervisorctl reload

Sources:
http://stackoverflow.com/questions/3792081/will-reloading-supervisord-cause-the-process-under-its-to-stop

Monday, March 25, 2013

launchctl / launchd on OSX

Launch definitions are in the form of plist documents

List jobs managed by launchctl (shows job label)
launchctl list

Show detail information about launchctl managed job
launchctl list job_label
i.e. launchctl list homebrew.mxcl.postgresql
# output will look like:
{
"Label" = "homebrew.mxcl.postgresql";
"LimitLoadToSessionType" = "Aqua";
"OnDemand" = false;
"LastExitStatus" = 0;
"PID" = 17312;
"TimeOut" = 30;
"StandardErrorPath" = "/usr/local/var/log/postgres/stderror.log";
"ProgramArguments" = (
"/opt/homebrew/bin/postgres";
"-D";
"/usr/local/var/postgres";
"-r";
"/usr/local/var/log/postgres/server.log";
);

};

Stop a job managed by launchctl
launchctl stop job_label

Good tool for making launchctl plists
http://sourceforge.net/projects/lingon/

Plists located in one of the following places
FILES
 ~/Library/LaunchAgents -  Per-user agents provided by the user. 
 /Library/LaunchAgents   -  Per-user agents provided by the administrator. 
 /Library/LaunchDaemons  -  System-wide daemons provided by the administrator. /System/Library/LaunchAgents -  Per-user agents provided by OS X.
 /System/Library/LaunchDaemons -  System-wide daemons provided by OS X.


https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html


Thursday, August 26, 2010

Django Management Commands

Django syncdb without prompts
python manage.py syncdb --noinput

http://docs.djangoproject.com/en/dev/ref/django-admin/