OpenBSD 5.3 i386
I have an rc.d(8) script to manage a python server that seems to start
up fine but doesn't manage to successfully match a running process or
stop it because (I think) it's not matching $pexp during script
execution. It does seem to match when testing manually from shell.
$ sudo /etc/rc.d/gunicorn start
gunicorn(ok)
$ ps auxwww | grep gun[i]
dspruell 29008 0.0 1.1 5900 8260 ?? S 1:10AM 0:38.75
python2.7: gunicorn: master [mysite.wsgi:application] (python2.7)
dspruell 7589 0.0 1.5 9580 11864 ?? S 1:10AM 0:04.71
python2.7: gunicorn: worker [mysite.wsgi:application] (python2.7)
dspruell 29731 0.0 1.5 9572 11860 ?? S 1:10AM 0:04.12
python2.7: gunicorn: worker [mysite.wsgi:application] (python2.7)
/etc/rc.d/gunicorn:
----------
#!/bin/sh
daemon="/usr/local/bin/gunicorn"
. /etc/rc.d/rc.subr
pexp="python.* gunicorn: master"
rc_cmd $1
----------
/etc/rc.conf.local:
----------
gunicorn_flags="-c /etc/gunicorn_django.py.ini mysite.wsgi:application"
gunicorn_user="dspruell"
----------
$ sudo /etc/rc.d/gunicorn check
$ echo $?
1
$ sudo sh -x /etc/rc.d/gunicorn check
...
+ daemon_user=dspruell
+ printf %s -c /etc/gunicorn_django.py.ini mysite.wsgi:application
+ daemon_flags= -c /etc/gunicorn_django.py.ini mysite.wsgi:application
+ daemon_flags=-c /etc/gunicorn_django.py.ini mysite.wsgi:application
+ readonly daemon_class
+ unset _rcflags _rcuser
+ pexp=/home/dspruell/venv.d/django-home/bin/gunicorn -c
/etc/gunicorn_django.py.ini mysite.wsgi:application
+ rcexec=su -l -c daemon -s /bin/sh dspruell -c
+ pexp=python.* gunicorn: master
+ rc_cmd check
$
## emulate rc_check() in /etc/rc.d/rc.subr:
$ pexp="python.* gunicorn: master"
$ pgrep -fl "^${pexp}"
29008 python2.7: gunicorn: master [mysite.wsgi:application]
$ pkill -f "^${pexp}"
$ pgrep -fl "^${pexp}"
$
There's a comment I didn't understand in pkill(1):
If any pattern operands are specified, they are used as regular
expressions to match the command name or, if -f is specified, the full
argument list of each process. However, presently OpenBSD will only keep
track of the first 16 characters of the command name for each process.
Attempts to match any characters after the first 16 of a command name
will silently fail.
Not sure if the 16 character limit applies with what I'm seeing but
I'm supposing not since the operations work manually from the shell.
I think the only modification I should have to make is the setting for
pexp to match the nonstandard process name and it shouldn't require
overriding any rc_* functions. What am I botching?
OpenBSD 5.3-stable (GENERIC) #0: Fri Jul 5 00:27:35 MST 2013
[email protected]:/usr/src/sys/arch/i386/compile/GENERIC
cpu0: AMD Duron(tm) processor ("AuthenticAMD" 686-class, 64KB L2 cache) 752 MHz
cpu0:
FPU,V86,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,MMXX,3DNOW2,3DNOW
real mem = 804777984 (767MB)
avail mem = 780640256 (744MB)
mainbus0 at root
bios0 at mainbus0: AT/286+ BIOS, date 06/24/02, BIOS32 rev. 0 @
0xfb470, SMBIOS rev. 2.2 @ 0xf0800 (44 entries)
bios0: vendor Award Software International, Inc. version "6.00 PG"
date 06/24/2002
bios0: VIA Technologies, Inc. VT8363
apm0 at bios0: Power Management spec V1.2 (slowidle)
acpi at bios0 function 0x0 not configured
pcibios0 at bios0: rev 2.1 @ 0xf0000/0xb8f8
pcibios0: PCI IRQ Routing Table rev 1.0 @ 0xfde30/160 (8 entries)
pcibios0: PCI Exclusive IRQs: 5 10 11 12
pcibios0: PCI Interrupt Router at 000:07:0 ("VIA VT82C596A ISA" rev 0x00)
pcibios0: PCI bus #1 is the last bus
bios0: ROM list: 0xc0000/0xa000 0xcc000/0x800
cpu0 at mainbus0: (uniprocessor)
pci0 at mainbus0 bus 0: configuration mode 1 (bios)
pchb0 at pci0 dev 0 function 0 "VIA VT8363 Host" rev 0x02
viaagp0 at pchb0: v2
agp0 at viaagp0: aperture at 0xd0000000, size 0x10000000
ppb0 at pci0 dev 1 function 0 "VIA VT8363 AGP" rev 0x00
pci1 at ppb0 bus 1
vga1 at pci1 dev 0 function 0 "3DFX Voodoo3" rev 0x01
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
pcib0 at pci0 dev 7 function 0 "VIA VT82C686 ISA" rev 0x22
pciide0 at pci0 dev 7 function 1 "VIA VT82C571 IDE" rev 0x10: ATA66,
channel 0 configured to compatibility, channel 1 configured to
compatibility
atapiscsi0 at pciide0 channel 0 drive 0
scsibus0 at atapiscsi0: 2 targets
cd0 at scsibus0 targ 0 lun 0: <PIONEER, DVD-ROM DVD-120, 1.22> ATAPI
5/cdrom removable
atapiscsi1 at pciide0 channel 0 drive 1
scsibus1 at atapiscsi1: 2 targets
cd1 at scsibus1 targ 0 lun 0: <ATAPI, CD-RW 48X16, A.UZ> ATAPI 5/cdrom removable
cd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 2
cd1(pciide0:0:1): using PIO mode 4, Ultra-DMA mode 2
wd0 at pciide0 channel 1 drive 0: <ST380021A>
wd0: 16-sector PIO, LBA, 76319MB, 156301488 sectors
wd1 at pciide0 channel 1 drive 1: <WDC WD200BB-75AUA1>
wd1: 16-sector PIO, LBA, 19092MB, 39102336 sectors
wd0(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 4
wd1(pciide0:1:1): using PIO mode 4, Ultra-DMA mode 4
uhci0 at pci0 dev 7 function 2 "VIA VT83C572 USB" rev 0x10: irq 11
uhci1 at pci0 dev 7 function 3 "VIA VT83C572 USB" rev 0x10: irq 11
viapm0 at pci0 dev 7 function 4 "VIA VT82C686 SMBus" rev 0x30: SMI
iic0 at viapm0
spdmem0 at iic0 addr 0x50: 512MB SDRAM non-parity PC133CL3
spdmem1 at iic0 addr 0x51: 128MB SDRAM non-parity PC133CL3
spdmem2 at iic0 addr 0x52: 128MB SDRAM non-parity PC133CL3
viapm0: 24-bit timer at 3579545Hz
auvia0 at pci0 dev 7 function 5 "VIA VT82C686 AC97" rev 0x20: irq 10
ac97: codec id 0x49434511 (ICEnsemble ICE1232)
ac97: codec features headphone, 18 bit DAC, 18 bit ADC, KS Waves 3D
audio0 at auvia0
xl0 at pci0 dev 9 function 0 "3Com 3c905C 100Base-TX" rev 0x78: irq
12, address 00:01:03:d4:3f:c6
exphy0 at xl0 phy 24: 3Com internal media interface
fxp0 at pci0 dev 10 function 0 "Intel 8255x" rev 0x05, i82558: irq 10,
address 00:08:c7:b2:8b:8f
inphy0 at fxp0 phy 1: i82555 10/100 PHY, rev. 0
fxp1 at pci0 dev 11 function 0 "Intel 8255x" rev 0x05, i82558: irq 11,
address 00:08:c7:ba:6f:95
inphy1 at fxp1 phy 1: i82555 10/100 PHY, rev. 0
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
lpt0 at isa0 port 0x378/4 irq 7
npx0 at isa0 port 0xf0/16: reported by CPUID; using exception 16
fdc0 at isa0 port 0x3f0/6 irq 6 drq 2
fd0 at fdc0 drive 0: density unknown
fd1 at fdc0 drive 1: density unknown
usb0 at uhci0: USB revision 1.0
uhub0 at usb0 "VIA UHCI root hub" rev 1.00/1.00 addr 1
usb1 at uhci1: USB revision 1.0
uhub1 at usb1 "VIA UHCI root hub" rev 1.00/1.00 addr 1
mtrr: Pentium Pro MTRR support
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on wd0a (f79e8f05439765a0.a) swap on wd0b dump on wd0b
--
Darren Spruell
[email protected]