Archive for August 2009

Rackspace Cloudを使ってみた。

written by shn, on Aug 25, 2009 8:02:00 PM.

メモリ1GBプラン?を借りる $0.06/h なので、ひと月$45ぐらいかな

pingは150msぐらい。

ダメスギはこんな感じ

[    0.000000] Linux version 2.6.24-23-xen (buildd@crested) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Mon Jan 26 03:09:12 UTC 2009 (Ubuntu 2.6.24-4.6-generic)
[    0.000000] Command line: root=/dev/sda1 ro xencons=tty console=tty1 clocksource=jiffies 
[    0.000000] BIOS-provided physical RAM map:
[    0.000000]  Xen: 0000000000000000 - 0000000040800000 (usable)
[    0.000000] Entering add_active_range(0, 0, 264192) 0 entries of 256 used
[    0.000000] end_pfn_map = 264192
[668358.384872] Entering add_active_range(0, 0, 264192) 0 entries of 256 used
[668358.387987] Zone PFN ranges:
[668358.387989]   DMA             0 ->     4096
[668358.387992]   DMA32        4096 ->  1048576
[668358.387993]   Normal    1048576 ->  1048576
[668358.387995] Movable zone start PFN for each node
[668358.387996] early_node_map[1] active PFN ranges
[668358.387998]     0:        0 ->   264192
[668358.388001] On node 0 totalpages: 264192
[668358.393477]   DMA zone: 56 pages used for memmap
[668358.393483]   DMA zone: 0 pages reserved
[668358.393485]   DMA zone: 4040 pages, LIFO batch:0
[668358.393902]   DMA32 zone: 3556 pages used for memmap
[668358.393905]   DMA32 zone: 256540 pages, LIFO batch:31
[668358.421618]   Normal zone: 0 pages used for memmap
[668358.421627]   Movable zone: 0 pages used for memmap
[668358.421659] No mptable found.
[668358.424600] PERCPU: Allocating 22368 bytes of per cpu data
[668358.424663] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260580
[668358.424669] Kernel command line: root=/dev/sda1 ro xencons=tty console=tty1 clocksource=jiffies 
[668358.425368] Initializing CPU#0
[668358.425568] PID hash table entries: 4096 (order: 12, 32768 bytes)
[668358.425616] Xen reported: 1994.998 MHz processor.
[    0.093560] console [tty1] enabled
[    0.093602] Console: colour dummy device 80x25
[    0.093606] console [tty1] enabled
[    0.094084] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes)
[    0.094496] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
[    0.094627] Software IO TLB disabled
[    0.103167] Memory: 946140k/1056768k available (2533k kernel code, 101908k reserved, 1331k data, 220k init)
[    0.169046] Calibrating delay using timer specific routine.. 4001.13 BogoMIPS (lpj=8002266)
[    0.169114] Security Framework initialized
[    0.169125] SELinux:  Disabled at boot.
[    0.169135] AppArmor: AppArmor initialized
[    0.169141] Failure registering capabilities with primary security module.
[    0.169165] Mount-cache hash table entries: 256
[    0.169325] CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
[    0.169333] CPU: L2 Cache: 512K (64 bytes/line)
[    0.169341] CPU: Physical Processor ID: 0
[    0.169344] CPU: Processor Core ID: 1
[    0.169364] SMP alternatives: switching to UP code
[    0.170091] Early unpacking initramfs... done
[    0.252310] Brought up 1 CPUs
[    0.252328] CPU0 attaching NULL sched-domain.
[    0.252986] net_namespace: 120 bytes
[    0.253002] failed to set up cpufreq notifier
[    0.270099] Time: 165:165:165  Date: 165/165/65
[    0.270190] NET: Registered protocol family 16
[    0.271737] CPU0 attaching NULL sched-domain.
[    0.287158] SMP alternatives: switching to SMP code
[    0.287791] CPU0 attaching sched-domain:
[    0.287795]  domain 0: span 03
[    0.287796]   groups:Initializing CPU#1
[    0.287803]  01 02
[    0.287811] CPU1 attaching sched-domain:
[    0.287813]  domain 0: span 03
[    0.287814]   groups: 02 01
[    0.000059] CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
[    0.000073] CPU: L2 Cache: 512K (64 bytes/line)
[    0.000080] CPU: Physical Processor ID: 0
[    0.000084] CPU: Processor Core ID: 1
[    0.288058] CPU0 attaching NULL sched-domain.
[    0.288060] CPU1 attaching NULL sched-domain.
[    0.298986] CPU0 attaching sched-domain:
[    0.298987]  domain 0: span 07
[    0.298989]   groups: 01 02 04
[    0.298991] CPU1 attaching sched-domain:
[    0.298992]  domain 0: span 07
[    0.298994]   groups: 02 04 01Initializing CPU#2
[    0.299001] 
[    0.299003] CPU2 attaching sched-domain:
[    0.299006]  domain 0: span 07
[    0.299007]   groups: 04 01 02
[    0.000072] CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
[    0.000081] CPU: L2 Cache: 512K (64 bytes/line)
[    0.000087] CPU: Physical Processor ID: 0
[    0.000091] CPU: Processor Core ID: 1
[    0.299180] CPU0 attaching NULL sched-domain.
[    0.299182] CPU1 attaching NULL sched-domain.
[    0.299184] CPU2 attaching NULL sched-domain.
[    0.310812] CPU0 attaching sched-domain:
[    0.310814]  domain 0: span 0f
[    0.310815]   groups:Initializing CPU#3
[    0.310818]  01 02 04 08
[    0.310823] CPU1 attaching sched-domain:
[    0.310824]  domain 0: span 0f
[    0.310826]   groups: 02 04 08 01
[    0.310829] CPU2 attaching sched-domain:
[    0.310830]  domain 0: span 0f
[    0.310832]   groups: 04 08 01 02
[    0.310839] CPU3 attaching sched-domain:
[    0.310840]  domain 0: span 0f
[    0.310841]   groups: 08 01 02 04
[    0.000053] CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
[    0.000060] CPU: L2 Cache: 512K (64 bytes/line)
[    0.000065] CPU: Physical Processor ID: 0
[    0.000068] CPU: Processor Core ID: 1
[    0.310886] Brought up 4 CPUs
[    0.311247] PCI: Fatal: No config space access function found
[    0.311255] PCI: setting up Xen PCI frontend stub
[    0.312098] ACPI: Interpreter disabled.
[    0.312108] Linux Plug and Play Support v0.97 (c) Adam Belay
[    0.312142] pnp: PnP ACPI: disabled
[    0.312362] xen_mem: Initialising balloon driver.
[    0.314883] Setting mem allocation to 1048576 kiB
[    0.315062] PCI: System does not support PCI
[    0.315069] PCI: System does not support PCI
[    0.322580] NET: Registered protocol family 8
[    0.322588] NET: Registered protocol family 20
[    0.322698] AppArmor: AppArmor Filesystem Enabled
[    0.323172] NET: Registered protocol family 2
[    0.358129] IP route cache hash table entries: 32768 (order: 6, 262144 bytes)
[    0.358500] TCP established hash table entries: 131072 (order: 9, 2097152 bytes)
[    0.359437] TCP bind hash table entries: 65536 (order: 8, 1048576 bytes)
[    0.359943] TCP: Hash tables configured (established 131072 bind 65536)
[    0.359952] TCP reno registered
[    0.370028] checking if image is initramfs... it is
[    0.460664] Freeing initrd memory: 76412k freed
[    0.185337] audit: initializing netlink socket (disabled)
[    0.185369] audit(1251197576.406:1): initialized
[    0.185902] VFS: Disk quotas dquot_6.5.1
[    0.185944] Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
[    0.186056] io scheduler noop registered
[    0.186062] io scheduler anticipatory registered
[    0.186066] io scheduler deadline registered
[    0.186098] io scheduler cfq registered (default)
[    0.189239] Xen virtual console successfully installed as tty1
[    0.189319] Event-channel device installed.
[    0.196374] Successfully initialized TPM backend driver.
[    0.213651] netfront: Initialising virtual ethernet driver.
[    0.534309] xen-vbd: registered block device major 8
[    0.534359] blkfront: sda1: barriers enabled
[    0.253875] blkfront: sda2: barriers enabled
[    0.566569] rtc: IRQ 8 is not free.
[    0.566664] Linux agpgart interface v0.102
[    0.567264] RAMDISK driver initialized: 16 RAM disks of 65536K size 1024 blocksize
[    0.567337] input: Macintosh mouse button emulation as /devices/virtual/input/input0
[    0.567446] PNP: No PS/2 controller found. Probing ports directly.
[    0.568305] i8042.c: No controller found.
[    0.574007] mice: PS/2 mouse device common for all mice
[    0.574050] cpuidle: using governor ladder
[    0.574186] NET: Registered protocol family 1
[    0.574262] registered taskstats version 1
[    0.574281] XENBUS: Device with no driver: device/console/0
[    0.574301]   Magic number: 1:252:3141
[    0.574423] /build/buildd/linux-2.6.24/debian/build/custom-source-xen/drivers/rtc/hctosys.c: unable to open rtc device (rtc0)
[    0.574437] Freeing unused kernel memory: 220k freed
[    1.101172] Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled
[    1.689595] loop: module loaded
[    1.734227] fuse init (API version 7.9)
[    1.508563] thermal: Unknown symbol acpi_processor_set_thermal_limit
[    1.553625] device-mapper: uevent: version 1.0.3
[    1.553703] device-mapper: ioctl: 4.12.0-ioctl (2007-10-02) initialised: dm-devel@redhat.com
[    1.594329] md: linear personality registered for level -1
[    1.606941] md: multipath personality registered for level -4
[    1.619622] md: raid0 personality registered for level 0
[    1.645283] md: raid1 personality registered for level 1
[    1.641772] xor: automatically using best checksumming function: generic_sse
[    1.658048]    generic_sse:  6129.000 MB/sec
[    1.658055] xor: using function: generic_sse (6129.000 MB/sec)
[    1.658888] async_tx: api initialized (async)
[    1.725313] raid6: int64x1   2055 MB/s
[    1.792632] raid6: int64x2   2592 MB/s
[    1.859932] raid6: int64x4   2603 MB/s
[    1.926625] raid6: int64x8   2004 MB/s
[    1.993496] raid6: sse2x1    2655 MB/s
[    2.060584] raid6: sse2x2    4740 MB/s
[    2.128145] raid6: sse2x4    4399 MB/s
[    2.128174] raid6: using algorithm sse2x2 (4740 MB/s)
[    2.128185] md: raid6 personality registered for level 6
[    2.128189] md: raid5 personality registered for level 5
[    2.128193] md: raid4 personality registered for level 4
[    2.207428] md: raid10 personality registered for level 10
[   12.425011] kjournald starting.  Commit interval 5 seconds
[   12.713647] EXT3-fs: mounted filesystem with ordered data mode.
[   13.559085] usbcore: registered new interface driver usbfs
[   13.559117] usbcore: registered new interface driver hub
[   13.559152] usbcore: registered new device driver usb
[   14.201891] udev: starting version 141
[   14.611203] evbug.c: Connected device: "Macintosh mouse button emulation", <NULL>
[   15.676061] SCSI subsystem initialized
[   15.890948] EXT3 FS on sda1, internal journal
[   16.296229] Adding 2097144k swap on /dev/sda2.  Priority:-1 extents:1 across:2097144k
[   16.582728] ip_tables: (C) 2000-2006 Netfilter Core Team
[   16.673512] nf_conntrack version 0.5.0 (16384 buckets, 65536 max)
[   16.841378] NET: Registered protocol family 10
[   16.841659] lo: Disabled Privacy Extensions
[   17.181698] NET: Registered protocol family 17
[   27.340132] eth0: no IPv6 routers present
[   32.485839] eth1: no IPv6 routers present
[  706.329680] udev: starting version 141

FAPWS3でSet-Cookieが出来ないっていう

written by shn, on Aug 10, 2009 2:58:00 AM.

今日は残ってる仕事をしに会社に行ったはずが、Zineのpluginとか作って遊んでたら一日が終わった。 そんななかで子一時間はまったのが、FAPWS3がSet-Cookieヘッダを食っちゃうって話。

FAPWS3駆動にしたZineでadmin panelにログインできないなー、おかしいなーと奮闘してたらコレが原因だった。

Unable to set cookie with Fapws3-0.2 not Set-Cookie headers send :(

fapws.baseのstart_responseが、Set-Cookieを食っちゃってるのが原因なので、cookie関連のコードを全部消しちまえばちゃんとzineが動くようになる。

なんでstart_response.set_cookie()なんてメソッドが用意されてんのかよくわからないけど、作者の勘違いかな。

以下パッチ:

--- base.py 2009-08-09 19:37:49.587425000 +0900
+++ fapws_base.py   2009-08-09 18:38:08.873789000 +0900
@@ -1,17 +1,13 @@
 # -*- coding: utf-8 -*-

 import datetime
-from Cookie import SimpleCookie, CookieError
 try:
     import cStringIO as StringIO
 except ImportError:
     import StringIO
 import traceback, sys, string

 status_reasons = {
     100: 'Continue',
@@ -90,7 +86,6 @@
         self.status_reasons = "OK"
         self.response_headers = {}
         self.exc_info = None
-        self.cookies = SimpleCookie()
         # NEW -- sent records whether or not the headers have been send to the
         # client
         self.sent= False
@@ -111,36 +106,11 @@
         key=str(key)
         val=str(val)
         self.response_headers[key]=val
-    def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=None):
-        self.cookies[key] = value
-        self.response_headers['Set-Cookie'] = self.cookies
-        if max_age:
-            self.cookies[key]['max-age'] = max_age
-        if expires:
-            if isinstance(expires, str):
-                self.cookies[key]['expires'] = expires
-            elif isinstance(expires, datetime.datetime):
-                expires = expires.strftime('%a, %d %b %Y %H:%M:%S GMT')
-            else:
-                raise CookieError, 'expires must be a datetime object or a string'
-            self.cookies[key]['expires'] = expires
-        if path:
-            self.cookies[key]['path'] = path
-        if domain:
-            self.cookies[key]['domain'] = domain
-        if secure:
-            self.cookies[key]['secure'] = secure
-    def delete_cookie(self, key):
-        if self.cookies:
-            self.cookies[key] = ''
-        self.cookies[key]['max-age'] = "0"
+
     def __str__(self):
         res = "HTTP/1.1 %s %s\r\n" % (self.status_code, self.status_reasons)
         for key, val in self.response_headers.items():
-            if key.upper() != "SET-COOKIE":
-                res += '%s: %s\r\n' % (key,val)
-        if self.cookies:
-            res+=str(self.cookies)+"\r\n"
+            res += '%s: %s\r\n' % (key,val)
         res += "\r\n"
         return str(res)

SQLAlchemyメモ

written by shn, on Aug 5, 2009 1:49:00 PM.

毎回ググるので、メモっておく。 このブログがSEOされて、このエントリが上位に来れば、次ググる時楽になる寸法だ!

INSERT IGNORE INTO ...

insert(..., prefixes=['IGNORE'])

SELECT ... FOR UPDATE

select(..., for_update=True)

随時更新したい。