Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Unit]
- Description=Keeps a tunnel to 'remote.example.com' open
- After=network.target
- [Service]
- User=autossh
- # -p [PORT]
- # -l [user]
- # -M 0 --> no monitoring
- # -N Just open the connection and do nothing (not interactive)
- # LOCALPORT:IP_ON_EXAMPLE_COM:PORT_ON_EXAMPLE_COM
- ExecStart=/usr/bin/autossh -M 0 -N -q -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -p 22 -l autossh remote.example.com -L 7474:127.0.0.1:7474 -i /home/autossh/.ssh/id_rsa
- [Install]
- WantedBy=multi-user.target
- [Unit]
- Description=AutoSSH service for ServiceABC on %i
- After=network.target
- [Service]
- Environment=AUTOSSH_GATETIME=30 AUTOSSH_LOGFILE=/var/log/autossh/%i.log AUTOSSH_PIDFILE=/var/run/autossh.%i.pid
- PIDFile=/var/run/autossh.%i.pid
- #Type=forking
- ExecStart=/usr/bin/autossh -M 40000 -NR 5000:127.0.0.1:5000 -i /opt/ServiceABC/.ssh/id_rsa_ServiceABC -l ServiceABC %i
- [Install]
- WantedBy=multi-user.target
- [user@anotherhost ~]$ sudo systemctl enable autossh@somehost.example.com
- ln -s '/etc/systemd/system/autossh@.service' '/etc/systemd/system/multi-user.target.wants/autossh@somehost.example.com.service'
- [user@anotherhost ~]$ sudo systemctl start autossh@somehost.example.com
- [user@anotherhost ~]$ sudo systemctl status autossh@somehost.example.com
- autossh@somehost.example.service - AutoSSH service for ServiceABC on somehost.example
- Loaded: loaded (/etc/systemd/system/autossh@.service; enabled)
- Active: active (running) since Tue 2015-10-20 13:19:01 EDT; 17s ago
- Main PID: 32524 (autossh)
- CGroup: /system.slice/system-autossh.slice/autossh@somehost.example.com.service
- ├─32524 /usr/bin/autossh -M 40000 -NR 5000:127.0.0.1:5000 -i /opt/ServiceABC/.ssh/id_rsa_ServiceABC -l ServiceABC somehost.example.com
- └─32525 /usr/bin/ssh -L 40000:127.0.0.1:40000 -R 40000:127.0.0.1:40001 -NR 5000:127.0.0.1:5000 -i /opt/ServiceABC/.ssh/id_rsa_ServiceABC -l ServiceABC somehost.example.com
- Oct 20 13:19:01 anotherhost.example.com systemd[1]: Started AutoSSH service for ServiceABC on somehost.example.com.
- [user@anotherhost ~]$ sudo systemctl status autossh@somehost.example.com
- [user@anotherhost ~]$ sudo systemctl status autossh@somehost.example.com
- autossh@somehost.example.com.service - AutoSSH service for ServiceABC on somehost.example.com
- Loaded: loaded (/etc/systemd/system/autossh@.service; enabled)
- Active: inactive (dead) since Tue 2015-10-20 13:24:10 EDT; 2s ago
- Process: 32524 ExecStart=/usr/bin/autossh -M 40000 -NR 5000:127.0.0.1:5000 -i /opt/ServiceABC/.ssh/id_rsa_ServiceABC -l ServiceABC %i (code=exited, status=0/SUCCESS)
- Main PID: 32524 (code=exited, status=0/SUCCESS)
- Oct 20 13:19:01 anotherhost.example.com systemd[1]: Started AutoSSH service for ServiceABC on somehost.example.com.
- Oct 20 13:24:10 anotherhost.example.com systemd[1]: Stopping AutoSSH service for ServiceABC on somehost.example.com...
- Oct 20 13:24:10 anotherhost.example.com systemd[1]: Stopped AutoSSH service for ServiceABC on somehost.example.com.
- [Unit]
- Description=az gearman worker
- After=gearman-job-server.service
- [Service]
- PIDFile=/var/run/gearman_worker_az%i.pid
- Type=simple
- User=www-data
- WorkingDirectory=/var/www/mysite.com/jobs/
- ExecStart=/usr/bin/php -f gearman_worker_az.php > /dev/null 2>&1
- Restart=on-success
- KillMode=process
- [Install]
- WantedBy=multi-user.target
- [Unit]
- Description=manages my worker service, instance %i
- After=multi-user.target
- [Service]
- PermissionsStartOnly=true
- Type=idle
- User=root
- ExecStart=/usr/local/virtualenvs/bin/python /path/to/my/script.py
- Restart=always
- TimeoutStartSec=10
- RestartSec=10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement